String

is the string data type for representing text.

<

external

(Fn [(Ref String a), (Ref String b)] Bool)

=

external

(Fn [(Ref String a), (Ref String b)] Bool)

>

external

(Fn [(Ref String a), (Ref String b)] Bool)

allocate

external

(Fn [Int, Char] String)

allocated?

defn

(Fn [(Ref String a)] Bool)

                        (allocated? s)
                    

checks if a String returned by String.allocate is not NULL. This is a safeguard against out-of-memory conditions.

alpha?

defn

(Fn [(Ref String a)] Bool)

                        (alpha? s)
                    

checks whether a string contains only alphabetical characters (a-Z).

alphanum?

defn

(Fn [(Ref String a)] Bool)

                        (alphanum? s)
                    

checks whether a string is alphanumerical.

append

external

(Fn [(Ref String a), (Ref String b)] String)

ascii-to-lower

defn

(Fn [(Ref String a)] String)

                        (ascii-to-lower s)
                    

converts each character in this string to lower case using tolower() from standard C library. Note: this will only work for ASCII characters.

ascii-to-upper

defn

(Fn [(Ref String a)] String)

                        (ascii-to-upper s)
                    

converts each character in this string to upper case using toupper() from standard C library. Note: this will only work for ASCII characters.

char-at

external

(Fn [(Ref String a), Int] Char)

chars

external

(Fn [(Ref String a)] (Array Char))

chomp

defn

(Fn [(Ref String a)] String)

                        (chomp s)
                    

trims a newline from the end of a string.

collapse-whitespace

defn

(Fn [(Ref String a)] String)

                        (collapse-whitespace s)
                    

collapses groups of whitespace into single spaces.

concat

defn

(Fn [(Ref (Array String) a)] String)

                        (concat strings)
                    

Returns a new string which is the concatenation of the provided strings.

contains?

defn

(Fn [(Ref String a), Char] Bool)

                        (contains? s c)
                    

Checks whether the string s contains the character c.

copy

external

(Fn [(Ref String a)] String)

count-char

defn

(Fn [(Ref String a), Char] Int)

                        (count-char s c)
                    

Returns the number of occurrences of c in the string s.

cstr

external

(Fn [(Ref String a)] (Ptr CChar))

delete

external

(Fn [String] ())

empty?

defn

(Fn [(Ref String a)] Bool)

                        (empty? s)
                    

Check if the string is the empty string.

ends-with?

defn

(Fn [(Ref String a), (Ref String b)] Bool)

                        (ends-with? s sub)
                    

Check if the string s ends with the string sub.

format

external

(Fn [(Ref String a), (Ref String b)] String)

from-bytes

external

(Fn [(Ref (Array Byte) a)] String)

from-chars

external

(Fn [(Ref (Array Char) a)] String)

from-cstr

external

(Fn [(Ptr CChar)] String)

hash

defn

(Fn [(Ref String a)] Int)

                        (hash k)
                    

defn

(Fn [(Ref String a)] Char)

                        (head s)
                    

Returns the character at start of string.

hex?

defn

(Fn [(Ref String a)] Bool)

                        (hex? s)
                    

checks whether a string is hexadecimal.

in?

defn

(Fn [(Ref String a), (Ref String b)] Bool)

                        (in? s sub)
                    

checks whether a string contains another string.

index-of

external

(Fn [(Ref String a), Char] Int)

index-of-from

external

(Fn [(Ref String a), Char, Int] Int)

join

defn

(Fn [(Ref String a), (Ref (Array String) b)] String)

                        (join sep strings)
                    

Returns a new string which is the concatenation of the provided strings separated by string sep.

join-with-char

defn

(Fn [Char, (Ref (Array String) a)] String)

                        (join-with-char sep strings)
                    

Returns a new string which is the concatenation of the provided strings separated by char sep.

length

external

(Fn [(Ref String a)] Int)

lines

defn

(Fn [(Ref String a)] (Array String))

                        (lines s)
                    

splits a string into lines.

lower?

defn

(Fn [(Ref String a)] Bool)

                        (lower? s)
                    

checks whether a string is all lowercase.

num?

defn

(Fn [(Ref String a)] Bool)

                        (num? s)
                    

checks whether a string is numerical.

pad-left

defn

(Fn [Int, Char, (Ref String a)] String)

                        (pad-left len pad s)
                    

Pads the left of a string with len bytes using the padding pad.

pad-right

defn

(Fn [Int, Char, (Ref String a)] String)

                        (pad-right len pad s)
                    

Pads the right of a string with len bytes using the padding pad.

prefix

defn

(Fn [(Ref String a), Int] String)

                        (prefix s a)
                    

Return the first a characters of the string s.

prn

external

(Fn [(Ref String a)] String)

random-sized

defn

(Fn [Int] String)

                        (random-sized n)
                    

repeat

defn

(Fn [Int, (Ref String a)] String)

                        (repeat n inpt)
                    

Returns a new string which is inpt repeated n times.

reverse

defn

(Fn [(Ref String a)] String)

                        (reverse s)
                    

Produce a new string which is s reversed.

slice

defn

(Fn [(Ref String a), Int, Int] String)

                        (slice s a b)
                    

Return part of a string, beginning at index a and ending at index b.

split-by

defn

(Fn [(Ref String a), (Ref (Array Char) b)] (Array String))

                        (split-by s separators)
                    

splits a string by separators.

starts-with?

defn

(Fn [(Ref String a), (Ref String b)] Bool)

                        (starts-with? s sub)
                    

Check if the string s begins with the string sub.

str

external

(Fn [(Ref String a)] String)

string-set!

external

(Fn [(Ref String a), Int, Char] ())

string-set-at!

external

(Fn [(Ref String a), Int, (Ref String b)] ())

suffix

defn

(Fn [(Ref String a), Int] String)

                        (suffix s b)
                    

Returns the suffix string starting at the bth character.

sum-length

defn

(Fn [(Ref (Array String) a)] Int)

                        (sum-length strings)
                    

Returns the sum of lengths from an array of Strings.

tail

external

(Fn [(Ref String a)] String)

to-bytes

external

(Fn [(Ref String a)] (Array Byte))

trim

defn

(Fn [(Ref String a)] String)

                        (trim s)
                    

trims whitespace from both sides of a string.

trim-left

defn

(Fn [(Ref String a)] String)

                        (trim-left s)
                    

trims whitespace from the left of a string.

trim-right

defn

(Fn [(Ref String a)] String)

                        (trim-right s)
                    

trims whitespace from the right of a string.

upper?

defn

(Fn [(Ref String a)] Bool)

                        (upper? s)
                    

checks whether a string is all uppercase.

words

defn

(Fn [(Ref String a)] (Array String))

                        (words s)
                    

splits a string into words.

zero

defn

(Fn [] String)

                        (zero)
                    

The empty string.