A general-purpose programming language with dynamic typing.
Saffron comes with a standard library of functions that provide support for console I/O, string manipulation and data conversion.
Write the given value to the console, followed by a new-line character at the end.
writeln(value)
Write the given value to the console (no new-line character at the end).
write(value)
Read a line of text from the console. Returns when the user presses ENTER.
readln()
Get the length of the source string.
str_length(source)
Get a sub-string of the source string.
The sub-string will be from the start position till the end position, inclusive.
Positions are zero-based i.e., the position of the first character is 0 and the position of the last character is length - 1.
Throws INDEX_OUT_OF_BOUNDS_EXCEPTION
if the value of start or
end is outside the range [0 to length-1]
.
str_substr(source, start, end)
Replace all occurrences of search with replace, in source.
This function does not modify the original string, but returns a new one.
str_replace(source, search, replace)
Trim whitespace from the beginning and end of the source string.
This function does not modify the original string, but returns a new one.
str_trim(source)
Find whether the source string contains the search string.
str_contains(source, search)
Find whether the source string starts with the search string.
str_startswith(source, search)
Find whether the source string ends with the search string.
str_endswith(source, search)
Parse the source string as a number.
Throws FORMAT_EXCEPTION
if source is not in a valid number format.
to_num(source)
Parse the source string as a boolean.
Throws FORMAT_EXCEPTION
if source is not a valid boolean value.
to_bool(source)
Convert the source value to its string representation. The source value can be a number, boolean or string
to_str(source)