+ 1 1
>> 2
+ (* 5 5) (+ 2 3)
>> 30
Integer represented in signed 64 bit integer.
1
(Max value is −9,223,372,036,854,775,807
, +9,223,372,036,854,775,807
)
A 64 bit floating point in the IEEE 754 double precision floating point format.
1.1
(fn '(arg1 arg2) '(+ arg1 arg2))
Pointer to a value, used in quoted expressions.
'(symbol1 symbol2)
Symbolic identifiers that evaluates to themselves
:symbol
>> :symbol
Functions that are built into the evaluator
(join 1 2 3)
(type join)
>> "Builtin"
"hello"
(type "hello")
>> "String"
Represents tree data structure.
(fn (1 2 3))
Represents unevaluated (quoted
) expressions
'(fn (1 2 3))'
Are constructed using {}
(hashmap '(:key 1))
Can also be constructed with the function hash-map
(hashmap '(:key 1))
(key hashmap :key)
Add key to hashmap
(assoc hashmap :key)
Remove key from hashmap
(dissoc hashmap :key)
Set global variables
(def :x 1)
x
>> 1
(def '(x y z) '(1 2 3))
z
>> 3
Set local variables
(defl :x 1)
x
>> 1
(defl '(x y z) '(1 2 3))
z
>> 3
Bind variables and evaluate expressions in a local context
(let '(firstname lastname) '("tom" "waits")
'(concat firstname " " lastname))
(if (== 1 1) '(+ 1 1) '(+ 2 2))
>> 4
Evaluates pairs with test and value, if test is true the value are returned. From standard library.
(cond
'((== x 0) "zero")
'((== x 1) "one")
'(true "other"))
Returns true if any of the elements match predicate. From the standard library.
(any not '(0 0))
Returns true if all elements match predicate. From the standard library.
(all not '(0 0))
Returns true if list is empty
(empty? '())
Returns true if data is lis type. (Standard library)
(list? (list 1 2))
Converts multi-dimensional lists to a one-dimensional one. (Standard library)
(flatten '(1 2) '(3 4))
Creates function and adds it to the global scope
(defn :plus-two '(x) '(+ 2 x))
(plus-two 2)
>> 4
Creates a lambda function
(defl '(plus-two) (fn '(x) '(+ 2 x)))
(plus-two 2)
>> 4
(defn '(show-all) '(&rest rest) '(print rest))
(show-all 1 2 3)
>> '(1 2 3)
Creates a function that always returns the same value. (Standard library)
((always 1) 2)
>> 1
Allows you to pipe a value through functions
(-> {:name "Bob"}
(curryassoc :age 4)
(curryassoc :type "dog"))
>> {:name "Bob" :age 4 :type "dog"}
Cast value to a string
(str 1)
>> "1"
(str "hi")
>> "hi"
(str list)
>> ""
(concat "hello " "John" " " "McCarthy")
>> "hello John McCarthy"
Transforms string into a list of chars
(str-split "scott walker")
>> '("s" "c" "o" "t" "t" " " "w" "a" "l" "k" "e" "r")
Convert a list of values to a string. (From the standard library).
(str-join '("s" "c" "o" "t" "t")'
>> "scott"
Convert string to lowercase
(lower-case "HELLO WORLD")
>> "hello world"
Convert string to uppercase
(upper-case "hello world")
>> "HELLO WORLD"
`(list 1 2 3)
>>> {1 2 3}
Operator | Binary | Unary |
---|---|---|
+ |
Addition | |
/ |
Division | |
- |
Subtraction | Arithmetic negation |
% |
Modulo | |
^ |
Exponent | |
min |
Min value | |
max |
Max value | |
== |
Equality | |
!= |
Inequality | |
< |
Less than | |
> |
Greater than | |
<= |
Less or eqal than | |
>= |
Greater or eqal than | |
and |
Logical and | |
or |
Logical or | |
not |
Logical negation |
These operators are called like this
(+ 1 1 1)
(/ 10 2)
(- 5 2)
(% 5 2)
(^ 10 3)
(min 1 100)
(max 200 1000)
(== 1 1)
(!= 1 0)
(< 1 10)
(<= 10 10)
(> 2 1)
(>= 2 2)
(and (== 1 1) 1 (> 3 2))
(or (== 1 0) (== 2 2))
(not 0)
Loads and evaluates external code.
(load "standard.ilisp")
>> ()
Exits the prompt.
exit ()