Builtins
Every builtin is lowerCamelCase and takes the data it works on last, so
partial application reads well: (map (add 1) xs),
(filter (lt 0) xs), (split "," line). Lowercase
names in a signature are type variables. The same reference is built into
the interpreter: run lbd docs [name], or :docs in
the REPL.
Numbers
-
add
Number -> Number -> Number - Sum of two numbers.
-
sub
Number -> Number -> Number (sub a b)isa - b.-
mul
Number -> Number -> Number - Product of two numbers.
-
div
Number -> Number -> Number (div a b)isa / b(IEEE: dividing by zero gives infinity).-
mod
Number -> Number -> Number - Remainder with the sign of the divisor, like Haskell’s
mod. -
pow
Number -> Number -> Number (pow base exponent).-
neg
Number -> Number - Negation.
-
abs
Number -> Number - Absolute value.
-
floor
Number -> Number - Largest integer not greater than the argument.
-
ceil
Number -> Number - Smallest integer not less than the argument.
-
round
Number -> Number - Nearest integer, halves away from zero.
-
sqrt
Number -> Number - Square root.
-
min
Number -> Number -> Number - Smaller of two numbers.
-
max
Number -> Number -> Number - Larger of two numbers.
Comparison
-
eq
a -> a -> Bool - Structural equality. Comparing functions is a runtime error.
-
neq
a -> a -> Bool - Structural inequality.
-
lt
a -> a -> Bool (lt a b)isa < b. Numbers, strings, booleans and lists are ordered.-
le
a -> a -> Bool (le a b)isa <= b.-
gt
a -> a -> Bool (gt a b)isa > b.-
ge
a -> a -> Bool (ge a b)isa >= b.-
compare
a -> a -> Number -1,0or1asais less than, equal to or greater thanb.
Booleans
-
true
Bool - Boolean truth.
-
false
Bool - Boolean falsehood.
-
not
Bool -> Bool - Boolean negation.
-
and
Bool -> Bool -> Bool - Conjunction; the second argument is only evaluated when needed.
-
or
Bool -> Bool -> Bool - Disjunction; the second argument is only evaluated when needed.
-
if
Bool -> a -> a -> a (if c t e)evaluates only the chosen branch.
Strings
-
concat
String -> String -> String - Joins two strings.
-
show
a -> String - Renders any value as source-like text (strings are quoted).
-
parseNumber
String -> Number - Parses a number, ignoring surrounding whitespace.
-
stringLength
String -> Number - Number of characters in a string.
-
chars
String -> List<String> - Splits a string into its characters.
-
split
String -> String -> List<String> (split delimiter text); the delimiter must not be empty.-
lines
String -> List<String> - Splits text into lines, accepting
\nand\r\n. -
join
String -> List<String> -> String (join separator parts).-
trim
String -> String - Removes leading and trailing whitespace.
Lists
-
length
List<a> -> Number - Number of elements.
-
isEmpty
List<a> -> Bool - Whether the list has no elements.
-
head
List<a> -> a - First element; an error on an empty list.
-
tail
List<a> -> List<a> - Everything but the first element; an error on an empty list.
-
get
Number -> List<a> -> a (get index list), zero-based; an error when out of bounds.-
cons
a -> List<a> -> List<a> - Prepends an element.
-
push
a -> List<a> -> List<a> - Appends an element at the end.
-
remove
Number -> List<a> -> List<a> (remove index list)without the element atindex.-
append
List<a> -> List<a> -> List<a> - Concatenates two lists.
-
map
(a -> b) -> List<a> -> List<b> - Applies a function to every element.
-
filter
(a -> Bool) -> List<a> -> List<a> - Keeps the elements satisfying a predicate.
-
foldl
(b -> a -> b) -> b -> List<a> -> b - Left fold:
(foldl f z [x, y])is(f (f z x) y). -
foldr
(a -> b -> b) -> b -> List<a> -> b - Right fold:
(foldr f z [x, y])is(f x (f y z)). -
reverse
List<a> -> List<a> - Reverses a list.
-
sort
List<a> -> List<a> - Stable ascending sort using the same ordering as
lt. -
range
Number -> Number -> List<Number> (range from to)counts fromfromup to, not including,to.-
zipWith
(a -> b -> c) -> List<a> -> List<b> -> List<c> - Combines two lists element-wise, stopping at the shorter.
-
transpose
List<List<a>> -> List<List<a>> - Turns rows into columns, truncated to the shortest row.
-
sum
List<Number> -> Number - Sum of all elements.
-
take
Number -> List<a> -> List<a> - The first
nelements. -
drop
Number -> List<a> -> List<a> - All but the first
nelements.
Input/output
No builtin matches that name.