String: Difference between revisions

From APL Wiki
Jump to navigation Jump to search
Miraheze>Adám Brudzewsky
No edit summary
Miraheze>Adám Brudzewsky
No edit summary
Line 1: Line 1:
{| class=vertical-navbox style="float:right; font-size:500%; margin:0 1ex;"
|<code><nowiki>'abc'</nowiki></code>
|}
In APL, a '''string''' is a [[vector]] of [[character]]s. Strings are written using single quotes, for example <source lang=apl inline>'string'</source>.
In APL, a '''string''' is a [[vector]] of [[character]]s. Strings are written using single quotes, for example <source lang=apl inline>'string'</source>.



Revision as of 17:29, 18 November 2019

'abc'

In APL, a string is a vector of characters. Strings are written using single quotes, for example 'string'.

A single character in quotes, such as 'a', creates a scalar character rather than a string. To create a singleton string the ravel function is typically used, as in ,'a'. Ravelling a quoted literal always produces a string. This consideration only applies to exactly one character (or two quotes representing a single character, as described in the next paragraph); quotes with no characters between them ('') form an empty string.

APL's string notation is very simple and includes only one escape: two adjacent single quotes within a string stand for one single quote character rather than ending the string and starting a new one. To strand strings together, put spaces between them. A newline character within a string produces an error. To produce newlines or other non-printing characters which would be inconvenient to include in the source, use an alternative character creation mechanism, such as Unicode Convert (⎕UCS).

Some users of nested APLs have proposed a dedicated string datatype to allow strings to be manipulated as a single entity, and in particular, to allow them to be compared with scalar functions. In flat APLs these problems are not felt so strongly because boxed arrays behave more like a simple datatype.

External links

APL syntax [edit]
General Comparison with traditional mathematicsPrecedenceTacit programming (Train, Hook, Split composition)
Array Numeric literalStringStrand notationObject literalArray notation (design considerations)
Function ArgumentFunction valenceDerived functionDerived operatorNiladic functionMonadic functionDyadic functionAmbivalent functionDefined function (traditional)DfnFunction train
Operator OperandOperator valenceTradopDopDerived operator
Assignment MultipleIndexedSelectiveModified
Other Function axisBracket indexingBranchStatement separatorQuad nameSystem commandUser commandKeywordDot notationFunction-operator overloadingControl structureComment