☯️ A Lisp dialect and toolchain. All in one binary.
Returns the floor of a number.
(math.floor 1.9) ; 1
Returns the ceiling of a number.
(math.ceil 1.1) ; 2
Returns the maximum value in a list of numbers.
(math.max (1 2 3)) ; 3
Returns the minimum value in a list of numbers.
(math.min (1 2 3)) ; 1
Returns a random number between 0 (inclusive) and 1 (exclusive).
(math.random) ; 0.123456
Returns the length of a string.
(string.length "hello") ; 5
Joins a list of strings with a separator.
(string.join "," ("foo" "bar")) ; "foo,bar"
Returns a substring from start to end indices.
(string.slice "hello" 1 4) ; "ell"
Checks if a string contains a substring.
(string.includes "hello" "ell") ; true
Trims whitespace from both ends of a string.
(string.trim " hello ") ; "hello"
Sleeps for the given number of milliseconds.
(flow.sleep 1000) ; sleeps for ~1 second
Counts elements in a list.
(list.count (1 2)) ; 2
Maps a lambda over a list.
(list.map (fn* (item idx) (+ item idx)) (1 2 3)) ; (1 3 5)
Applies a lambda to each element in a list (for side effects).
(list.each (fn* (item idx) (print item)) (1 2 3)) ; nil
Creates a list from the given arguments.
(list.from 1 2 3) ; (1 2 3)
Creates a list by repeatedly calling a lambda.
(list.times (fn* (idx) idx) 3) ; (0 1 2)
Returns the nth element of a list, or nil if out of bounds.
(list.nth 1 (10 20 30)) ; 20
Filters a list using a lambda predicate.
(list.filter (fn* (item idx) (> item 0)) (-1 0 1 2)) ; (1 2)
Adds numbers together.
(+ 1 2 3) ; 6
Subtracts numbers from the first argument.
(- 5 2 1) ; 2
Multiplies numbers together.
(* 2 3 4) ; 24
Divides the first argument by the rest.
(/ 8 2 2) ; 2
Performs division with modulo.
(% 4 2) ; 0
Checks if two values are equal.
(= 1 1) ; true
Checks if the first value is less than the second.
(< 1 2) ; true
Checks if the first value is greater than the second.
(> 2 1) ; true
Checks if two values are not equal.
(!= 1 2) ; true
Checks if the first value is less than or equal to the second.
(<= 1 2) ; true
Checks if the first value is greater than or equal to the second.
(>= 2 1) ; true
Logical AND for two boolean values.
(and true false) ; false
Logical OR for two boolean values.
(or true false) ; true
Stringifies an atom and writes it to stdout. Use io.print
to format output.
(io.stdout "hello")
Stringifies an atom and writes it to stderr.
(io.stderr "error")
Writes a formatted string to stdout. Specifiers:
%s
for strings%d
for numbers%i
casts a string to an integer%f
casts a string to a float(io.printf "hello %s %d" ("world" 42))
Writes the question on stdout and waits for user input.
(io.readline "What is your favorite food? ") ; "USER_TYPED_CONTENT"
Clear the console output.
(io.clear)