Login
7 branches 0 tags
Ben (X13/Arch) Simplified things a little 0643405 9 days ago 1260 Commits
nujel / docs / stable / 1.4-arithmetic.md

[ 1.3 - Numbers | 1.5 - Symbols & Keywords ]


Arithmetic operations

Nujel supports most widely used operators directly and tries to use the same names as Clojure does.

[+ 1 2 3 4] ; You can add as many numbers as you want
; => 10
[+ 1 2 [+ 3 4]]
; => 10
[+ [+ 1 2] [+ 3 4]]
; => 10
[+ 1 -2] ; You can also use negative numbers in additions
; => -1
[+ 1 [- 2]] ; - can also be used to negate numbers
; => -1
[+ 1 [- [+ 1 1]]] ; Results of a calculation can also be negated
; => -1
[+ 1 :two "drei"] ; You can only calculate with numbers
; => :type-error
[def my-var 123]
[* 2 my-var] ; Using variables is fine as long as they are of a numeric type
; => 246
[def my-string "tausend"]
[* 2 my-string]
; => :type-error

[ 1.3 - Numbers | 1.5 - Symbols & Keywords ]