throw value
to use with tryreturn value
to use with trytry value on_success on_error
value being either a thrown one or a returned on
compose f g
returningf ∘ g
left val
returning a function of 2 higher order functions: when called the left most argument is applied toval
right val
works likeleft val
but it's the right most argument which will be applied toval
flip function value
returning a function taking one argumentbis
: callingfunction bis value
list:forEach list function
the function will be applied to every element of the list, one after the otherlist:product list
returns the product of every element with the others (they must be all numbers)list:sum list
returns the sum of all the elements in the list (they must be all numbers)list:drop list count
drops the firstcount
elements of the listlist:filter list function
returns a new list filtered byfunction
(takes an element of the list, returns a boolean)list:map list function
maps every element with the given functionlist:reduce list function
reduces a given list with a function taking two elements, returning onelist:take list count
takes only the firstcount
elements of the listlist:unzip list
unzip a list of 2 elements listslist:zip a b
zips two lists into a list of 2 elements lists
math:abs val
returns the absolute value ofval
math:even val
returns true ifval
is evenmath:odd val
returns true ifval
is oddmath:min a b
returns the minimum between a and bmath:max a b
returns the maximum between a and bmath:pow x a
returns x to the power of amath:sqrt x
returns the square root of xmath:divs n
returns the divisors of nmaths:fibo n p c
returns the result of the fibonacci function performed on n (p & c are accumulators)
range a b
returns a range object in [a, b[range:forEach range function
callsfunction
on each value ofrange
range:filter range function
filter the given range usingfunction
, taking a single argument and returning a boolrange:map range function
maps every value of the range withfunction
and returns a list of those valuesrange:reduce range function
reduces a given range with a function taking two elements, returning one
str:toLower str
returnsstr
in lowercasestr:toUpper str
returnsstr
in uppercasestr:reverse str
reversesstr
str:slice str start length
takes a slice ofstart
, given a starting index and a slice lengthstr:split str sep
splitsstr
in multiple substrings each time the separator (a single char) is foundstr:replace str pattern replace
replacespattern
instr
withreplace
os:home_dir
returns the home directory of the current user
switch value tests
iterates overtests
, a list of of 2 elements lists:[[value function] [value function]...]
, whenvalue
is found in the tests, the corresponding function (no arguments) is called.