Skip to content

String (type)

Paul Lipkowski edited this page Feb 16, 2022 · 14 revisions

String is an entity type used in PapajScript. It stores text strings.

History

String is the second entity type introduced in PS. Its debut was on April 26, 2018 along with release of the 0.4.0 version. The 0.4.2 version was the last version that treated all alphanumerical input as strings, unless it was not a pre-built function. Starting from version 0.4.3, the unknown input triggers an exception, unless quoted.

Features

  • All strings are quoted – "This" is String, this is not.
  • Since May 5, 2020 all functions operating on strings are wrapped to a String package.
  • The strings may be run as they were PS script. See String.eval (or String.run in the pre-0.5.1 versions) in String package for more information.
  • Using sort on a set of strings sorts them by their size – the strsort is found since 0.4.3.
  • Since October 1, 2020 (stable version 0.5.1) the strings are zero-based and evaluated in C-like style by default (it may be changed by using a directive @stringstart)

Arithmetics

String type supports following artithmetic operations:

  • String String + (an equivalent String.join or String.concat)
  • String String - (an equivalent of String.delete)
  • String Number - (an equivalent of String.delete)
  • Number String * (an equivalent of String.copies)
  • String Number * (an equivalent of String.copies)
  • String Number / (an equivalent of String.divide)
  • String String / (an equivalent of String.divide)

Note: All arithmetical operations do not require any additional packages

Examples

  • "Hello world!"
  • "Shalom!"
  • "h"
Clone this wiki locally