go back
arithmetic
(+ 2 2)=4
(- 7 5)=2
(* 2 8)=16
(/ 5 5)=1
(^ 3 3)=27
(- 10 (+ 2 3))=5
(* (/ 10 5) 6)=12
(< 10 5)=false
(< 5 10)=true
(= 4 4)=true
(= 4 5)=false
logic
(not true)=false
(not false)=true
(not (not true))=true
(not (not (not false)))=true
(and true true)=true
(and true false)=false
(and false true)=false
(and false false)=false
(or true true)=true
(or true false)=true
(or false true)=true
(or false false)=false
(or true (and false false))=true
(and (and false false) false)=false
if statments
(if true 11 12)=11
(if false 11 12)=12
(if true 7 5)=7
(if false 66 88)=88
(if true true false)=true
(if false true false)=false
(if (if true false true) 7 8)=8
(if true (if true 7 8) false)=7
definitions
(define foo 7)
foo=7
(+ foo foo)=14
(define bar 7)
bar=7
(- bar bar)=0
(define age 17)
age=17
(define age (+ 1 age))
age=18
(+ age age)=36
functional programs
;;traditional notation:
;;f(x)=x+1
;;f(7)=8
(define f (function (x) (+ 1 x)))
(f 7)=8
(f 8)=9
(f 11)=12
(define double (function double (x) (* x 2)))
(doube 10)=20
(define foo (double (double 20)))
(+ foo 2)=42
(double (double (double 2)))=8
(define can-drive (function (x) (< x 21)))
(can-drive 44)=true
(can-drive 5)=false
(define add (function (x y) (+ x y)))
(add 2 2)=4