string¶
Strings in Minilang can contain any sequence of bytes, including 0 bytes.
Index and find methods however work on UTF-8 characters, byte sequences that are not valid UTF-8 are handled gracefully but the results are probably not very useful.
Every string is also an address so address methods can also be used to work at the byte level if necessary.
Indexing a string starts at 1, with the last character at String:length. Negative indices are counted form the end, -1 is the last character and -String:length is the first character.
When creating a substring, the first index is inclusive and second index is exclusive. The index 0 refers to just beyond the last character and can be used to take a substring to the end of a string.
fun mlstringbuffercount()TBD
fun mlstringcheckcache()TBD
meth (Arg₁: any):sha256TBD
meth (Buffer: string::buffer):append(Value: any)Appends a representation of
ValuetoBuffer.meth (Arg₁: string::buffer):append(Arg₂: any, Arg₃: function, ...)TBD
meth (Arg₁: buffer):put(Arg₂: string::buffer)TBD
type byte::order < enum::LittleEndian::BigEndian
meth (Arg₁: string::buffer):append(Arg₂: decimal)TBD
meth (N: integer) * (String: string): stringReturns
StringconcatentatedNtimes.5 * "abc" :> "abcabcabcabcabc"
meth (Codepoint: integer):char: stringReturns a UTF-8 string containing the character with unicode codepoint
Codepoint.meth (Codepoint: integer):utf8: stringReturns a UTF-8 string containing the character with unicode codepoint
Codepoint.meth (Arg₁: string::buffer):append(Arg₂: rational)TBD
type regex < functionA regular expression.
fun regex(String: string): regex | errorCompiles
Stringas a regular expression. Returns an error ifStringis not a valid regular expression.regex("[0-9]+") :> /[0-9]+/ regex("[0-9") :> error("RegexError", "Missing ']'")
meth (Arg₁: regex) != (Arg₂: regex): regex | nilReturns
Arg₂ifArg₁ != Arg₂andnilotherwise.r"[0-9]+" != r"[A-Za-z0-9_]+" :> /[A-Za-z0-9_]+/ r"[A-Za-z0-9_]+" != r"[0-9]+" :> /[0-9]+/ r"[0-9]+" != r"[0-9]+" :> nil
meth (Arg₁: regex) < (Arg₂: regex): regex | nilReturns
Arg₂ifArg₁ < Arg₂andnilotherwise.r"[0-9]+" < r"[A-Za-z0-9_]+" :> /[A-Za-z0-9_]+/ r"[A-Za-z0-9_]+" < r"[0-9]+" :> nil r"[0-9]+" < r"[0-9]+" :> nil
meth (Arg₁: regex) <= (Arg₂: regex): regex | nilReturns
Arg₂ifArg₁ <= Arg₂andnilotherwise.r"[0-9]+" <= r"[A-Za-z0-9_]+" :> /[A-Za-z0-9_]+/ r"[A-Za-z0-9_]+" <= r"[0-9]+" :> nil r"[0-9]+" <= r"[0-9]+" :> /[0-9]+/
meth (A: regex) <> (B: regex): integerCompares
AandBlexicographically and returns-1,0or1respectively. Mainly for using regular expressions as keys in maps.r"[0-9]+" <> r"[A-Za-z0-9_]+" :> -1 r"[A-Za-z0-9_]+" <> r"[0-9]+" :> 1 r"[0-9]+" <> r"[0-9]+" :> 0
meth (Arg₁: regex) = (Arg₂: regex): regex | nilReturns
Arg₂ifArg₁ = Arg₂andnilotherwise.r"[0-9]+" = r"[A-Za-z0-9_]+" :> nil r"[A-Za-z0-9_]+" = r"[0-9]+" :> nil r"[0-9]+" = r"[0-9]+" :> /[0-9]+/
meth (Arg₁: regex) > (Arg₂: regex): regex | nilReturns
Arg₂ifArg₁ > Arg₂andnilotherwise.r"[0-9]+" > r"[A-Za-z0-9_]+" :> nil r"[A-Za-z0-9_]+" > r"[0-9]+" :> /[0-9]+/ r"[0-9]+" > r"[0-9]+" :> nil
meth (Arg₁: regex) >= (Arg₂: regex): regex | nilReturns
Arg₂ifArg₁ >= Arg₂andnilotherwise.r"[0-9]+" >= r"[A-Za-z0-9_]+" :> nil r"[A-Za-z0-9_]+" >= r"[0-9]+" :> /[0-9]+/ r"[0-9]+" >= r"[0-9]+" :> /[0-9]+/
meth (Regex: regex):pattern: stringReturns the pattern used to create
Regex.r"[0-9]+":pattern :> "[0-9]+"
meth (Buffer: string::buffer):append(Value: regex)Appends a representation of
ValuetoBuffer.type string < address, sequenceA string of characters in UTF-8 encoding.
fun string(Value: any): stringReturns a representation of
Valueas a string.string(100) :> "100" string(nil) :> "nil" string("Hello world!\n") :> "Hello world!\n" string([1, 2, 3]) :> "[1, 2, 3]"
fun regex::escape(String: string): stringEscapes characters in
Stringthat are treated specially in regular expressions.regex::escape("Word (?)\n") :> "Word \\(\\?\\)\\n"
fun string::escape(String: string): stringEscapes characters in
String.string::escape("\'Hello\nworld!\'") :> "\\\'Hello\\nworld!\\\'"
meth (Arg₁: string) != (Arg₂: string): string | nilReturns
Arg₂ifArg₁ != Arg₂andnilotherwise."Hello" != "World" :> "World" "World" != "Hello" :> "Hello" "Hello" != "Hello" :> nil "abcd" != "abc" :> "abc" "abc" != "abcd" :> "abcd"
meth (String: string) !? (Pattern: regex): string | nilReturns
Stringif it does not matchPatternandnilotherwise."2022-03-08" !? r"([0-9]+)[/-]([0-9]+)[/-]([0-9]+)" :> nil "Not a date" !? r"([0-9]+)[/-]([0-9]+)[/-]([0-9]+)" :> "Not a date"
meth (String: string) % (Pattern: regex): tuple[string] | nilMatches
StringwithPatternreturning a tuple of the matched components, ornilif the pattern does not match."2022-03-08" % r"([0-9]+)[/-]([0-9]+)[/-]([0-9]+)" :> (2022-03-08, 2022, 03, 08) "Not a date" % r"([0-9]+)[/-]([0-9]+)[/-]([0-9]+)" :> nil
meth (String: string) */ (Pattern: regex): tuple[string, string]Splits
Stringat the last occurence ofPatternand returns the two substrings in a tuple."2022/03/08" */ r"[/-]" :> (2022/03, 08) "2022-03-08" */ r"[/-]" :> (2022-03, 08)
meth (String: string) */ (Pattern: string): tuple[string, string]Splits
Stringat the last occurence ofPatternand returns the two substrings in a tuple."2022/03/08" */ "/" :> (2022/03, 08)
meth (A: string) + (B: string): stringReturns
AandBconcatentated."Hello" + " " + "world" :> "Hello world"
meth (Start: string) .. (Limit: string): string::intervalReturns a interval from the first character of
Startto the first character ofLimit(inclusive).meth (String: string) / (Pattern: string): listReturns a list of substrings from
Stringby splitting around occurences ofPattern. Adjacent occurences ofPatterndo not create empty strings."The cat snored as he slept" / " " :> ["The", "cat", "snored", "as", "he", "slept"] "2022/03/08" / "/" :> ["2022", "03", "08"]
meth (String: string) /* (Pattern: regex): tuple[string, string]Splits
Stringat the first occurence ofPatternand returns the two substrings in a tuple."2022/03/08" /* r"[/-]" :> (2022, 03/08) "2022-03-08" /* r"[/-]" :> (2022, 03-08)
meth (String: string) /* (Pattern: string): tuple[string, string]Splits
Stringat the first occurence ofPatternand returns the two substrings in a tuple."2022/03/08" /* "/" :> (2022, 03/08)
meth (Arg₁: string) < (Arg₂: string): string | nilReturns
Arg₂ifArg₁ < Arg₂andnilotherwise."Hello" < "World" :> "World" "World" < "Hello" :> nil "Hello" < "Hello" :> nil "abcd" < "abc" :> nil "abc" < "abcd" :> "abcd"
meth (Arg₁: string) <= (Arg₂: string): string | nilReturns
Arg₂ifArg₁ <= Arg₂andnilotherwise."Hello" <= "World" :> "World" "World" <= "Hello" :> nil "Hello" <= "Hello" :> "Hello" "abcd" <= "abc" :> nil "abc" <= "abcd" :> "abcd"
meth (A: string) <> (B: string): integerCompares
AandBlexicographically and returns-1,0or1respectively."Hello" <> "World" :> -1 "World" <> "Hello" :> 1 "Hello" <> "Hello" :> 0 "abcd" <> "abc" :> 1 "abc" <> "abcd" :> -1
meth (Arg₁: string) = (Arg₂: string): string | nilReturns
Arg₂ifArg₁ = Arg₂andnilotherwise."Hello" = "World" :> nil "World" = "Hello" :> nil "Hello" = "Hello" :> "Hello" "abcd" = "abc" :> nil "abc" = "abcd" :> nil
meth (Arg₁: string) > (Arg₂: string): string | nilReturns
Arg₂ifArg₁ > Arg₂andnilotherwise."Hello" > "World" :> nil "World" > "Hello" :> "Hello" "Hello" > "Hello" :> nil "abcd" > "abc" :> "abc" "abc" > "abcd" :> nil
meth (Arg₁: string) >= (Arg₂: string): string | nilReturns
Arg₂ifArg₁ >= Arg₂andnilotherwise."Hello" >= "World" :> nil "World" >= "Hello" :> "Hello" "Hello" >= "Hello" :> "Hello" "abcd" >= "abc" :> "abc" "abc" >= "abcd" :> nil
meth (String: string) ? (Pattern: regex): string | nilReturns
Stringif it matchesPatternandnilotherwise."2022-03-08" ? r"([0-9]+)[/-]([0-9]+)[/-]([0-9]+)" :> "2022-03-08" "Not a date" ? r"([0-9]+)[/-]([0-9]+)[/-]([0-9]+)" :> nil
meth (String: string)[Interval: integer::interval]: stringReturns the substring of
Stringcorresponding toIntervalinclusively.meth (String: string)[Index: integer]: string | nilReturns the substring of
Stringof length 1 atIndex.let S := "λ:😀 → 😺" map(-7 .. 7 => (2, 2 -> S[_])) :> {-7 is "λ", -6 is ":", -5 is "😀", -4 is " ", -3 is "→", -2 is " ", -1 is "😺", 0, 1 is "λ", 2 is ":", 3 is "😀", 4 is " ", 5 is "→", 6 is " ", 7 is "😺"}
meth (String: string)[Start: integer, End: integer]: string | nilReturns the substring of
StringfromStarttoEnd - 1inclusively.meth (String: string):after(Delimiter: string): string | nilReturns the portion of
Stringafter the 1st occurence ofDelimiter, ornilif no occurence if found."2022/03/08":after("/") :> "03/08"
meth (String: string):after(Delimiter: string, N: integer): string | nilReturns the portion of
Stringafter theN-th occurence ofDelimiter, ornilif noN-th occurence if found. IfN < 0then occurences are counted from the end ofString."2022/03/08":after("/", 2) :> "08"
meth (String: string):before(Delimiter: string): string | nilReturns the portion of
Stringbefore the 1st occurence ofDelimiter, ornilif no occurence if found."2022/03/08":before("/") :> "2022"
meth (String: string):before(Delimiter: string, N: integer): string | nilReturns the portion of
Stringbefore theN-th occurence ofDelimiter, ornilif noN-th occurence if found. IfN < 0then occurences are counted from the end ofString."2022/03/08":before("/", 2) :> "2022/03"
meth (Arg₁: string):cnameTBD
meth (String: string):code: integerReturns the unicode codepoint of the first UTF-8 character of
String."A":code :> 65 "😀️":code :> 128512
meth (Haystack: string):contains(Pattern: regex): string | nilReturns the
Haystackif it containsPatternornilotherwise."The cat snored as he slept":contains(r"[a-z]{3}") :> "The cat snored as he slept" "The cat snored as he slept":contains(r"[0-9]+") :> nil
meth (Haystack: string):contains(Needle: string): string | nilReturns the
Haystackif it containsPatternornilotherwise."The cat snored as he slept":contains("cat") :> "The cat snored as he slept" "The cat snored as he slept":contains("dog") :> nil
meth (String: string):count: integerReturns the number of UTF-8 characters in
String. Use:sizeto get the number of bytes."Hello world":count :> 11 "Hello world":size :> 11 "λ:😀 → 😺":count :> 7 "λ:😀 → 😺":size :> 16
meth (String: string):ctype: string::ctypeReturns the unicode type of the first character of
String.map("To €2 á\n" => (2, 2 -> :ctype)) :> {"T" is Lu, "o" is Ll, " " is Zs, "€" is Sc, "2" is Nd, "á" is Ll, "\n" is Cc}
meth (String: string):ends(Suffix: string): string | nilReturns
Stringif it ends withSuffixandnilotherwise."Hello world":ends("world") :> "Hello world" "Hello world":ends("cake") :> nil
meth (String: string):escape: stringReturns
Stringwith white space, quotes and backslashes replaced by escape sequences."\t\"Text\"\r\n":escape :> "\\t\\\"Text\\\"\\r\\n"
meth (Haystack: string):find(Pattern: regex): integer | nilReturns the index of the first occurence of
PatterninHaystack, ornilif no occurence is found."The cat snored as he slept":find(r"[a-z]{3}") :> 5 "The cat snored as he slept":find(r"[0-9]+") :> nil
meth (Haystack: string):find(Pattern: regex, Start: integer): integer | nilReturns the index of the first occurence of
PatterninHaystackat or afterStart, ornilif no occurence is found."The cat snored as he slept":find(r"s[a-z]+", 1) :> 9 "The cat snored as he slept":find(r"s[a-z]+", 10) :> 22 "The cat snored as he slept":find(r"s[a-z]+", -6) :> 22
meth (Haystack: string):find(Needle: string): integer | nilReturns the index of the first occurence of
NeedleinHaystack, ornilif no occurence is found."The cat snored as he slept":find("cat") :> 5 "The cat snored as he slept":find("dog") :> nil
meth (Haystack: string):find(Needle: string, Start: integer): integer | nilReturns the index of the first occurence of
NeedleinHaystackat or afterStart, ornilif no occurence is found."The cat snored as he slept":find("s", 1) :> 9 "The cat snored as he slept":find("s", 10) :> 17 "The cat snored as he slept":find("s", -6) :> 22
meth (Haystack: string):find2(Pattern: regex): tuple[integer, string] | nilReturns
(Index, Match)whereIndexis the first occurence ofPatterninHaystack, ornilif no occurence is found."The cat snored as he slept":find2(r"[a-z]{3}") :> (5, cat) "The cat snored as he slept":find2(r"[0-9]+") :> nil
meth (Haystack: string):find2(Pattern: regex, Start: integer): tuple[integer, string] | nilReturns
(Index, Match)whereIndexis the first occurence ofPatterninHaystackat or afterStart, ornilif no occurence is found."The cat snored as he slept":find2(r"s[a-z]+", 1) :> (9, snored) "The cat snored as he slept":find2(r"s[a-z]+", 10) :> (22, slept) "The cat snored as he slept":find2(r"s[a-z]+", -6) :> (22, slept)
meth (Haystack: string):find2(Pattern: regex, Start: tuple::integer::string): tuple[integer, string] | nilReturns
(Index, Match)whereIndexis the first occurence ofPatterninHaystackat or afterStart, ornilif no occurence is found."The cat snored as he slept":find2(r"s[a-z]+", 1) :> (9, snored) "The cat snored as he slept":find2(r"s[a-z]+", 10) :> (22, slept) "The cat snored as he slept":find2(r"s[a-z]+", -6) :> (22, slept)
meth (Haystack: string):find2(Needle: string): tuple[integer, string] | nilReturns
(Index, Needle)whereIndexis the first occurence ofNeedleinHaystack, ornilif no occurence is found."The cat snored as he slept":find2("cat") :> (5, cat) "The cat snored as he slept":find2("dog") :> nil
meth (Haystack: string):find2(Needle: string, Start: integer): tuple[integer, string] | nilReturns
(Index, Needle)whereIndexis the first occurence ofNeedleinHaystackat or afterStart, ornilif no occurence is found."The cat snored as he slept":find2("s", 1) :> (9, s) "The cat snored as he slept":find2("s", 10) :> (17, s) "The cat snored as he slept":find2("s", -6) :> (22, s)
meth (Haystack: string):find2(Needle: string, Start: tuple::integer::string): tuple[integer, string] | nilReturns
(Index, Needle)whereIndexis the first occurence ofNeedleinHaystackat or afterStart, ornilif no occurence is found."The cat snored as he slept":find2("s", 1) :> (9, s) "The cat snored as he slept":find2("s", 10) :> (17, s) "The cat snored as he slept":find2("s", -6) :> (22, s)
meth (String: string):length: integerReturns the number of UTF-8 characters in
String. Use:sizeto get the number of bytes."Hello world":length :> 11 "Hello world":size :> 11 "λ:😀 → 😺":length :> 7 "λ:😀 → 😺":size :> 16
meth (String: string):limit(Length: integer): stringReturns the prefix of
Stringlimited toLength."Hello world":limit(5) :> "Hello" "Cake":limit(5) :> "Cake"
meth (String: string):lower: stringReturns
Stringwith each character converted to lower case."Hello World":lower :> "hello world"
meth (String: string):ltrim: stringReturns a copy of
Stringwith characters inCharsremoved from the start." \t Hello \n":ltrim :> "Hello \n"
meth (String: string):ltrim(Chars: string): stringReturns a copy of
Stringwith characters inCharsremoved from the start." \t Hello \n":trim(" \n") :> "\t Hello"
meth (A: string):max(B: string): integerReturns
max(A, B)"Hello":max("World") :> "World" "World":max("Hello") :> "World" "abcd":max("abc") :> "abcd" "abc":max("abcd") :> "abcd"
meth (A: string):min(B: string): integerReturns
min(A, B)"Hello":min("World") :> "Hello" "World":min("Hello") :> "Hello" "abcd":min("abc") :> "abc" "abc":min("abcd") :> "abc"
meth (String: string):normalize(Norm: string::norm): stringReturns a normalized copy of
Stringusing the normalizer specified byNorm.let S := "𝕥𝕖𝕩𝕥" :> "𝕥𝕖𝕩𝕥" S:normalize(string::norm::NFD) :> "𝕥𝕖𝕩𝕥"
meth (String: string):offset(Index: integer): integerReturns the byte position of the
Index-th character ofString.let S := "λ:😀 → 😺" list(1 .. S:length, S:offset(_)) :> [0, 2, 3, 7, 8, 11, 12]
meth (String: string):precount: integerReturns the number of UTF-8 characters in
String. Use:sizeto get the number of bytes."Hello world":count :> 11 "Hello world":size :> 11 "λ:😀 → 😺":count :> 7 "λ:😀 → 😺":size :> 16
meth (String: string):replace(I: integer, Fn: function): stringReturns a copy of
Stringwith theString[I]is replaced byFn(String[I])."hello world":replace(1, :upper) :> "Hello world"
meth (String: string):replace(I: integer, Fn: integer, Arg₄: function): stringReturns a copy of
Stringwith theString[I, J]is replaced byFn(String[I, J])."hello world":replace(1, 6, :upper) :> "HELLO world"
meth (String: string):replace(I: integer, J: integer, Replacement: string): stringReturns a copy of
Stringwith theString[I, J]is replaced byReplacement."Hello world":replace(1, 6, "Goodbye") :> "Goodbye world" "Hello world":replace(-6, 0, ", how are you?") :> "Hello, how are you?"
meth (String: string):replace(I: integer, Replacement: string): stringReturns a copy of
Stringwith theString[I]is replaced byReplacement."Hello world":replace(6, "_") :> "Hello_world"
meth (String: string):replace(Replacements: map): stringEach key in
Replacementscan be either a string or a regex. Each value inReplacementscan be either a string or a function. Returns a copy ofStringwith each matching string or regex fromReplacementsreplaced with the corresponding value. Functions are called with the matched string or regex subpatterns."the dog snored as he slept":replace({ r" ([a-z])" is fun(Match, A) '-{A:upper}', "nor" is "narl" }) :> "the-Dog-Snarled-As-He-Slept"
meth (String: string):replace(Pattern: regex, Fn: function): stringReturns a copy of
Stringwith each occurence ofPatternreplaced byFn(Match, Sub₁, ..., Subₙ)whereMatchis the actual matched text andSubᵢare the matched subpatterns."the cat snored as he slept":replace(r" ([a-z])", fun(Match, A) '-{A:upper}') :> "the-Cat-Snored-As-He-Slept"
meth (String: string):replace(Pattern: regex, Replacement: string): stringReturns a copy of
Stringwith each occurence ofPatternreplaced byReplacement."Hello world":replace(r"l+", "bb") :> "Hebbo worbbd"
meth (String: string):replace(Pattern: string, Replacement: string): stringReturns a copy of
Stringwith each occurence ofPatternreplaced byReplacement."Hello world":replace("l", "bb") :> "Hebbbbo worbbd"
meth (String: string):replace2(Replacements: map): stringEach key in
Replacementscan be either a string or a regex. Each value inReplacementscan be either a string or a function. Returns a copy ofStringwith each matching string or regex fromReplacementsreplaced with the corresponding value. Functions are called with the matched string or regex subpatterns."the dog snored as he slept":replace2({ r" ([a-z])" is fun(Match, A) '-{A:upper}', "nor" is "narl" }) :> (the-Dog-Snarled-As-He-Slept, 6)
meth (String: string):replace2(Pattern: regex, Replacement: string): stringReturns a copy of
Stringwith each occurence ofPatternreplaced byReplacement."Hello world":replace2(r"l+", "bb") :> (Hebbo worbbd, 2)
meth (String: string):replace2(Pattern: string, Replacement: string): stringReturns a copy of
Stringwith each occurence ofPatternreplaced byReplacement."Hello world":replace2("l", "bb") :> (Hebbbbo worbbd, 3)
meth (String: string):reverse: stringReturns a string with the characters in
Stringreversed."Hello world":reverse :> "dlrow olleH"
meth (String: string):rtrim: stringReturns a copy of
Stringwith characters inCharsremoved from the end." \t Hello \n":rtrim :> " \t Hello"
meth (String: string):rtrim(Chars: string): stringReturns a copy of
Stringwith characters inCharsremoved from the end." \t Hello \n":rtrim(" \n") :> " \t Hello"
meth (String: string):starts(Pattern: regex): string | nilReturns
Stringif it starts withPatternandnilotherwise."Hello world":starts(r"[A-Z]") :> "Hello world" "Hello world":starts(r"[0-9]") :> nil
meth (String: string):starts(Prefix: string): string | nilReturns
Stringif it starts withPrefixandnilotherwise."Hello world":starts("Hello") :> "Hello world" "Hello world":starts("cake") :> nil
meth stringtable(Arg₁: string)TBD
meth (String: string):title: stringReturns
Stringwith the first character and each character after whitespace converted to upper case and each other case converted to lower case."hello world":title :> "Hello World" "HELLO WORLD":title :> "Hello World"
meth (String: string):trim: stringReturns a copy of
Stringwith whitespace removed from both ends." \t Hello \n":trim :> "Hello"
meth (String: string) / (Pattern: regex, Index: integer): listReturns a list of substrings from
Stringby splitting around occurences ofPattern. Only theIndexsubgroup matches are removed from the output substrings."<A>-<B>-<C>" / (r">(-)<", 1) :> ["<A>", "<B>", "<C>"]
meth (String: string) / (Pattern: regex): listReturns a list of substrings from
Stringby splitting around occurences ofPattern. IfPatterncontains subgroups then only the subgroup matches are removed from the output substrings."2022/03/08" / r"[/-]" :> ["2022", "03", "08"] "2022-03-08" / r"[/-]" :> ["2022", "03", "08"]
meth (String: string):trim(Chars: string): stringReturns a copy of
Stringwith characters inCharsremoved from both ends." \t Hello \n":trim(" \n") :> "\t Hello"
meth (String: string):upper: stringReturns
Stringwith each character converted to upper case."Hello World":upper :> "HELLO WORLD"
meth (Arg₁: string):utf8TBD
meth (A: string) ~ (B: string): integerReturns the edit distance between
AandB."cake" ~ "cat" :> 2 "yell" ~ "hello" :> 2 "say" ~ "goodbye" :> 6 "goodbye" ~ "say" :> 6 "λ:😀 → Y" ~ "λ:X → 😺" :> 2
meth (A: string) ~> (B: string): integerReturns an asymmetric edit distance from
AtoB."cake" ~> "cat" :> 1 "yell" ~> "hello" :> 2 "say" ~> "goodbye" :> 6 "goodbye" ~> "say" :> 3 "λ:😀 → Y" ~> "λ:X → 😺" :> 4
meth (Buffer: string::buffer):append(Value: string)Appends
ValuetoBuffer.meth (Arg₁: string::buffer):append(Arg₂: string, Arg₃: string)TBD
type string::bufferA string buffer that automatically grows and shrinks as required.
meth string::buffer(): string::bufferReturns a new
string::buffermeth string::buffer(Arg₁: address): string::bufferReturns a new
string::buffermeth (Buffer: string::buffer):get: stringReturns the contents of
Bufferas a string and clearsBuffer. .. deprecated:: 2.5.0Use
Buffer:restinstead.let B := string::buffer() B:write("Hello world") B:get :> "Hello world" B:get :> ""
meth (Arg₁: string::buffer):grow(Arg₂: sequence)TBD
meth (Buffer: string::buffer):length: integerReturns the number of bytes currently available in
Buffer.let B := string::buffer() B:write("Hello world") B:length :> 11
meth (Buffer: string::buffer):read16: integerReads a signed 16-bit value from
Buffer.let B := string::buffer("Hello world!\n") :> <string::buffer> B:read16 :> 25928
meth (Buffer: string::buffer):read16(Arg₂: byte::order): integerReads a signed 16-bit value from
Buffer.let B := string::buffer("Hello world!\n") :> <string::buffer> B:readu16(address::LE) :> error("MethodError", "no method found for readu16(string::buffer, address::byteorder)") B:readu16(address::BE) :> error("MethodError", "no method found for readu16(string::buffer, address::byteorder)")
meth (Buffer: string::buffer):read16(Arg₂: byte::order): integerReads a signed 16-bit value from
Buffer.let B := string::buffer("Hello world!\n") :> <string::buffer> B:read16(address::LE) :> 25928 B:read16(address::BE) :> 27756
meth (Buffer: string::buffer):read32: integerReads a signed 32-bit value from
Buffer.let B := string::buffer("Hello world!\n") :> <string::buffer> B:read32 :> 1819043144
meth (Buffer: string::buffer):read32(Arg₂: byte::order): integerReads a signed 32-bit value from
Buffer.let B := string::buffer("Hello world!\n") :> <string::buffer> B:read32(address::LE) :> 1819043144 B:read32(address::BE) :> 1864398703
meth (Buffer: string::buffer):read32(Arg₂: byte::order): integerReads a signed 32-bit value from
Buffer.let B := string::buffer("Hello world!\n") :> <string::buffer> B:readu32(address::LE) :> error("MethodError", "no method found for readu32(string::buffer, address::byteorder)") B:readu32(address::BE) :> error("MethodError", "no method found for readu32(string::buffer, address::byteorder)")
meth (Buffer: string::buffer):read64: integerReads a signed 64-bit value from
Buffer.let B := string::buffer("Hello world!\n") :> <string::buffer> B:read64 :> 8031924123371070792
meth (Buffer: string::buffer):read64(Arg₂: byte::order): integerReads a signed 64-bit value from
Buffer.let B := string::buffer("Hello world!\n") :> <string::buffer> B:readu64(address::LE) :> error("MethodError", "no method found for readu64(string::buffer, address::byteorder)") B:readu64(address::BE) :> error("MethodError", "no method found for readu64(string::buffer, address::byteorder)")
meth (Buffer: string::buffer):read64(Arg₂: byte::order): integerReads a signed 64-bit value from
Buffer.let B := string::buffer("Hello world!\n") :> <string::buffer> B:read64(address::LE) :> 8031924123371070792 B:read64(address::BE) :> nil
meth (Buffer: string::buffer):read8: integerReads a signed 8-bit value from
Buffer.let B := string::buffer("\xCC") :> <string::buffer> B:read8 :> -52
meth (Buffer: string::buffer):readu16: integerReads a signed 16-bit value from
Buffer.let B := string::buffer("Hello world!\n") :> <string::buffer> B:readu16 :> 25928
meth (Buffer: string::buffer):readu32: integerReads a signed 32-bit value from
Buffer.let B := string::buffer("Hello world!\n") :> <string::buffer> B:readu32 :> 1819043144
meth (Buffer: string::buffer):readu64: integerReads a signed 64-bit value from
Buffer.let B := string::buffer("Hello world!\n") :> <string::buffer> B:readu64 :> 8031924123371070792
meth (Buffer: string::buffer):readu8: integerReads a signed 8-bit value from
Buffer.let B := string::buffer("\xCC") :> <string::buffer> B:readu8 :> 204
meth (Buffer: string::buffer):rest: stringReturns the contents of
Bufferas a string and clearsBuffer.let B := string::buffer() B:write("Hello world") B:rest :> "Hello world" B:rest :> ""
meth (Buffer: string::buffer):unread(Bytes: address): string::bufferInserts the contents of
Bytesat the start ofBuffer.meth (Buffer: string::buffer):write(Value₁, : any, ...): integerWrites each
Valueᵢin turn toBuffer.let B := string::buffer() B:write("1 + 1 = ", 1 + 1) B:rest :> "1 + 1 = 2"
meth (Buffer: string::buffer):write16(Value: integer): bufferWrites
ValuetoBufferas an 16-bit signed value. Uses the platform byte order.let B := string::buffer() :> <string::buffer> B:write16(12345) :> <string::buffer> B:rest :> "90"
meth (Buffer: string::buffer):write16(Value: integer, Arg₃: byte::order): bufferWrites
ValuetoBufferas an 16-bit signed value. Uses the given byte order.let B := string::buffer() :> <string::buffer> B:write16(12345, address::LE) :> <string::buffer> B:rest :> "90" B:write16(12345, address::BE) :> <string::buffer> B:rest :> "09"
meth (Buffer: string::buffer):write32(Value: integer): bufferWrites
ValuetoBufferas an 32-bit signed value. Uses the platform byte order.let B := string::buffer() :> <string::buffer> B:write32(12345) :> <string::buffer> B:rest :> "90\0\0"
meth (Buffer: string::buffer):write32(Value: integer, Arg₃: byte::order): bufferWrites
ValuetoBufferas an 32-bit signed value. Uses the given byte order.let B := string::buffer() :> <string::buffer> B:write32(12345, address::LE) :> <string::buffer> B:rest :> "90\0\0" B:write32(12345, address::BE) :> <string::buffer> B:rest :> "\0\009"
def MLStringProperties: string::propertiesTBD
meth (Buffer: string::buffer):write64(Value: integer): bufferWrites
ValuetoBufferas an 64-bit signed value. Uses the platform byte order.let B := string::buffer() :> <string::buffer> B:write64(12345) :> <string::buffer> B:rest :> "90\0\0\0\0\0\0"
meth (Buffer: string::buffer):write64(Value: integer, Arg₃: byte::order): bufferWrites
ValuetoBufferas an 64-bit signed value. Uses the given byte order.let B := string::buffer() :> <string::buffer> B:write64(12345, address::LE) :> <string::buffer> B:rest :> "90\0\0\0\0\0\0" B:write64(12345, address::BE) :> <string::buffer> B:rest :> "\0\0\0\0\0\009"
meth (Buffer: string::buffer):write8(Value: integer): bufferWrite
ValuetoBufferas an 8-bit signed value.let B := string::buffer() :> <string::buffer> B:write8(120) :> <string::buffer> B:rest :> "x"
meth (Buffer: string::buffer):writeu16(Value: integer): bufferWrites
ValuetoBufferas an 16-bit unsigned value. Uses the platform byte order.let B := string::buffer() :> <string::buffer> B:writeu16(12345) :> <string::buffer> B:rest :> "90"
meth (Buffer: string::buffer):writeu16(Value: integer, Arg₃: byte::order): bufferWrites
ValuetoBufferas an 16-bit unsigned value. Uses the given byte order.let B := string::buffer() :> <string::buffer> B:writeu16(12345, address::LE) :> <string::buffer> B:rest :> "90" B:writeu16(12345, address::BE) :> <string::buffer> B:rest :> "09"
meth (Buffer: string::buffer):writeu32(Value: integer): bufferWrites
ValuetoBufferas an 32-bit unsigned value. Uses the platform byte order.let B := string::buffer() :> <string::buffer> B:writeu32(12345) :> <string::buffer> B:rest :> "90\0\0"
meth (Buffer: string::buffer):writeu32(Value: integer, Arg₃: byte::order): bufferWrites
ValuetoBufferas an 32-bit unsigned value. Uses the given byte order.let B := string::buffer() :> <string::buffer> B:writeu32(12345, address::LE) :> <string::buffer> B:rest :> "90\0\0" B:writeu32(12345, address::BE) :> <string::buffer> B:rest :> "\0\009"
meth (Buffer: string::buffer):writeu64(Value: integer): bufferWrites
ValuetoBufferas an 64-bit unsigned value. Uses the platform byte order.let B := string::buffer() :> <string::buffer> B:writeu64(12345) :> <string::buffer> B:rest :> "90\0\0\0\0\0\0"
meth (Buffer: string::buffer):writeu64(Value: integer, Arg₃: byte::order): bufferWrites
ValuetoBufferas an 64-bit unsigned value. Uses the given byte order.let B := string::buffer() :> <string::buffer> B:writeu64(12345, address::LE) :> <string::buffer> B:rest :> "90\0\0\0\0\0\0" B:writeu64(12345, address::BE) :> <string::buffer> B:rest :> "\0\0\0\0\0\009"
meth (Buffer: string::buffer):writeu8(Value: integer): bufferWrite
ValuetoBufferas an 8-bit signed value.let B := string::buffer() :> <string::buffer> B:writeu8(120) :> <string::buffer> B:rest :> "x"
type string::charset < sequenceTBD
meth (Arg₁: string::charset)[Arg₂: integer]TBD
meth (Arg₁: string::charset):countTBD
type string::ctype < enum::Cn- General Other Types::Lu- Uppercase Letter::Ll- Lowercase Letter::Lt- Titlecase Letter::Lm- Modifier Letter::Lo- Other Letter::Mn- Non Spacing Mark::Me- Enclosing Mark::Mc- Combining Spacing Mark::Nd- Decimal Digit Number::Nl- Letter Number::No- Other Number::Zs- Space Separator::Zl- Line Separator::Zp- Paragraph Separator::Cc- Control Char::Cf- Format Char::Co- Private Use Char::Cs- Surrogate::Pd- Dash Punctuation::Ps- Start Punctuation::Pe- End Punctuation::Pc- Connector Punctuation::Po- Other Punctuation::Sm- Math Symbol::Sc- Currency Symbol::Sk- Modifier Symbol::So- Other Symbol::Pi- Initial Punctuation::Pf- Final Punctuation
type string::interval < integer::intervalTBD
type string::norm < enum::NFC::NFD::NFKC::NFKD
meth (Arg₁: string::properties) :: (Arg₂: string)TBD
type string::property < sequenceTBD
meth (Arg₁: string::property) :: (Arg₂: string)TBD
meth (Arg₁: string::property)[Arg₂: integer]TBD
meth (Arg₁: string::property)[Arg₂: string]TBD
meth (Arg₁: string::property):maxTBD
meth (Arg₁: string::property):minTBD
meth stringcharset(Arg₁: string::property::value)TBD
meth (Arg₁: string::buffer):append(Arg₂: string::property::value)TBD
type string::tableTBD
meth (Arg₁: string::table):describeTBD
meth (Arg₁: string::table):splice(Arg₂: integer, Arg₃: integer, Arg₄: string)TBD
meth (Arg₁: string::buffer):append(Arg₂: string::table)TBD
meth stringtable()TBD
fun string::switch(Cases: string|regex, ...)Implements
switchfor string values. Case values must be strings or regular expressions.for Pet in ["cat", "dog", "mouse", "fox"] do switch Pet: string case "cat" do print("Meow!\n") case "dog" do print("Woof!\n") case "mouse" do print("Squeak!\n") else print("???!") end end :> nil
Meow! Woof! Squeak! ???!
meth (Arg₁: visitor):const(Arg₂: buffer)TBD
meth (Arg₁: visitor):copy(Arg₂: buffer)TBD