Standard library
There are two components to the standard library: built-in functions and a distribution of functionality defined in Hurl.
Built-ins
Built-ins are functions which evaluate as an expression to a value; when you use them you do not have to catch the result but may assign it directly.
These are the built-ins that are defined, with *args
representing any number of arguments:
print(*args)
: prints all arguments with no separators; evaluates tonil
println(*args)
:print
, but with a newline; evaluates tonil
is_digit(x)
: evaluates totrue
ifx
is an ASCII digit, andfalse
otherwiseas_num(x)
: evaluates tox
converted to a number, or panics if that failsas_str(x)
: evaluates tox
as a stringstr_chars(s)
: evaluates to a list containing all the chars that are in the strings
, and panics if called on a non-string argumentstr_lines(s)
: evaluates to a list containing all the lines that are in the strings
, and panics if called on a non-string argumentlen(xs)
: evaluates to the length of the list or string represented byxs
, and panics if provided any other typeslice(xs, start, end)
: evaluates to the substring or sublist ofxs
starting fromstart
and going toend
or the end of the list, whichever is sooner; panics if given a non-list and non-string argumentat(xs, index)
: evaluates to the element ofxs
at theindex
location (remember, it's 1-indexed)set(xs, index, val)
: evaluates to a copy of the listxs
with theindex
th element replaced withval
floor(x)
: evaluates to the value passed in rounded down to the nearest integerceil(x)
: evaluates to the value passed in rounded up to the nearest integerread_file(x)
: evaluates to the content of the file at pathx
as a string, or panics if the file does not exist or cannot be readtrim(s)
: evaluates to the strings
with all leading and trailing whitespace removed; this can be implemented in pure Hurl, but I'm sorry, I was tired while doing the Advent of Code problems okay?
Hurl stdlib
If you check out the main Hurl repo, there are some included files in the lib/
directory which are the standard library.
You can browse them in the repo and new standard library functions are welcome.