Functions for the String type.
char_at :: (String, 1) -> String compare_string :: (String, String) -> 1 concatenate :: (String, String) -> String format :: for_type t: t -> String int2str :: for_unit a, D!b, E!c: for_index D, E: (a*D!b per E!c, a*D!b per E!c) -> String join_strings :: (List(String), String) -> String num2str :: for_unit a, I!u, J!v: for_index I, J: (a*I!u per J!v, a*I!u per J!v) -> String num2string :: for_unit a, I!u, J!v: for_index I, J: (a*I!u per J!v, decimals, a*I!u per J!v) -> String pad :: (String, String, 1, String) -> String pad_left :: (String, 1, String) -> String pad_right :: (String, 1, String) -> String parse_num :: (String) -> 1 split_string :: (String, String) -> List(String) string_ends_with :: (String, String) -> Boole string_length :: (String) -> 1 string_starts_with :: (String, String) -> Boole substring :: (String, 1, 1) -> String trim :: (String) -> String unit2string :: for_unit a: (a) -> String
:: (String, 1) -> String
The character at position pos mod n of the original string, where n is the length of the original string.
It is an error if the string is empty.
Primitive function
:: (String, String) -> 1
Alphanumerical ordering of strings. Returns -1 if x comes before y, returns 1 if x comes after y and returns 0 if x equals y.
Primitive function
:: (String, String) -> String
A string that is the concatenation of the given strings.
Primitive function
:: for_type t: t -> String
Limited string interpolation. Supports limited forms of the %s, %d and %f directives.
The %s directive prints any value, not just strings.
The %nd directive prints a matrix. If the n parameter is
provided the string is padded to size n.
The %n.kf directive prints a matrix. If the n parameter is
provided the string is padded to size n. If the k parameter is provided
the string is pritned with k number of decimals.
This function is unsafe as the type shows. Any error is thrown at runtime.
Primitive function
:: for_unit a, D!b, E!c: for_index D, E: (a*D!b per E!c, a*D!b per E!c) -> String
Shorthand for num2string(x, 0, unit)
:: (List(String), String) -> String
Contatenates all strings with the seperator between them all.
For example join_strings(["a", "bb", "ccc"], "++") is
"a++bb++ccc"
:: for_unit a, I!u, J!v: for_index I, J: (a*I!u per J!v, a*I!u per J!v) -> String
Convert a matrix to a string using the current number of decimals.
Shorthand for num2string(x, nr_decimals(), y).
:: for_unit a, I!u, J!v: for_index I, J: (a*I!u per J!v, decimals, a*I!u per J!v) -> String
Convert a matrix to a string.
The last argument must be a literal unit. It is converted to text at compile time.
The second argument is the number of decimals.
For example num2string(1/3*|metre|, 5, |metre|) "0,33333m"
:: (String, String, 1, String) -> String
Adds characters between the left and the right string to make the concatenation at least as long as the requested size.
For example pad_left("foo", "bar", 10, "abc") is "fooabcabar"
Returns the string unchanged if it is not smaller than the requested size
Primitive function
:: (String, 1, String) -> String
Adds characters to the left of a string to make it at least as long as the requested size.
For example pad_left("foo", 8, "abc") is
"abcabfoo"
Returns the string unchanged if it is not smaller than the requested size
:: (String, 1, String) -> String
Adds characters to the right of a string to make it at least as long as the requested size.
For example pad_right("foo", 8, "abc") is
"fooabcab"
Returns the string unchanged if it is not smaller than the requested size
:: (String) -> 1
Reads a number from a string.
Primitive function
:: (String, String) -> List(String)
Splits a string for all occurences of the second string.
For example
split_string("x + y++ + z--", "+")
gives
["x ", " y", "", " ", " ", "z--"]
Primitive function
:: (String, String) -> Boole
Does the given string end with the given suffix?
:: (String) -> 1
The length of the given string.
Primitive function
:: (String, String) -> Boole
Does the given string start with the given prefix?
:: (String, 1, 1) -> String
A substring of the given string from start (inclusive) to end (exclusive).
Returns a string of length end - start. The chartacter at the i-th position is the character at position (start + i) mod n of the original string, where n is the length of the original string.
Returns the empty string if the original string is empty.
:: (String) -> String
Copy of the given string with any whitespace removed from the start and from the end.
Primitive function
:: for_unit a: (a) -> String
Convert a matrix to a string.
The last argument must be a literal unit. It is converted to text at compile time.
The second argument is the number of decimals.
For example num2string(1/3*|metre|, 5, |metre|) gives "0,33333m"
Primitive function
Version v0.6.0, 2026-03-05T15:49:19.105701932+01:00[Europe/Amsterdam]