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

[ 1.5 - Symbols & Keywords | 1.7 - Quote & Quasiquote ]


Variables

You can define new variables using def and give old variables a new value using set!. You can use let if you only want a variable visible to a small section of code.

my-temp ; You can access a variables value by evaluating the symbol
; => :unbound-variable
[def my-temp 123] ; Of course it needs to be defined first
; => 123
[set! my-temp 234]
my-temp
; => 234
[def double [fn [a] [* a a]]] ; You can also define functions this way, although defn should be preferred because it gives better error messages/stack traces
[double 4]
; => 16

[ 1.5 - Symbols & Keywords | 1.7 - Quote & Quasiquote ]