A string is a vector of characters (see section Characters), they are generally used for storing and manipulating pieces of text. Jade puts no restrictions on the values which may be stored in a string -- specifically, the null character (`^@') may be stored with no problems.
The read syntax of a string is a double quote character, followed by the
contents of the string, the object is terminated by a second double quote
character. For example, "abc" is the read syntax of the string
`abc'.
Any backslash characters in the string's read syntax introduce an escape sequence; one or more of the following characters are treated specially to produce the next actual character in the string.
The following escape sequences are supported (all are shown without their leading backslash `\' character).
\^C ;A Ctrl-c character (ASCII value 3) \^@ ;The NUL character (ASCII value 0)
t if its argument is a string.
(make-string 3)
=> " "
(make-string 2 ?$)
=> "$$"
Each of the args may be a string, a character or a list or vector of characters. Characters are stored in strings modulo 256.
(concat "foo" "bar")
=> "foobar"
(concat "a" ?b)
=> "ab"
(concat "foo" [?b ?a ?r])
=> "foobar"
(concat)
=> ""
(substring "xxyfoozwx" 3 6)
=> "foo"
(substring "xyzfoobar" 3)
=> "foobar"
t is
returned, else nil.
(string= "one" "one")
=> t
(string= "one" "two")
=> nil
Note that an alternate way to compare strings (or anything!) is to use the
equal function.
t if string1 is `less' than string2.
This is determined by comparing the two strings a character at a time, the
first pair of characters which do not match each other are then compared
with a normal `less-than' function.
In Jade the standard < function understands strings so string<
is just a macro calling that function.
(string< "abc" "abd")
=> t
(string< "abc" "abb")
=> nil
Functions are also available which match regular expressions with strings (see section Searching and Matching Functions) and which apply a mapping to each character in a string (see section Translation Functions).
Go to the first, previous, next, last section, table of contents.