CS 378: Examples of Function Calls

=> (first '(a b c))
a

=> (first '((a b) '(c d)))
(a b)

=> (rest '(a b c))
(b c)

=> (rest '((a b) (c d)))
((c d))

=> (length '(a b c))
3

=> (length '((a b) (c d)))
2

=> (reverse '(a b c))
(c b a)

=> (reverse '((a b) (c d)))
((c d) (a b))

=> (append '(a b) '(c d e))
(a b c d e)

=> (member 'c '(a b c d e))
(c d e)

=> (assocl 'two '((one uno) (two dos) (three tres)))
(two dos)

=> (intersection '(a b c) '(a c e))
(a c)

=> (union '(a b c) '(a c e))
(b a c e)

=> (set-difference '(a b c) '(a c e))
(b)

=> (set= '(a b c) '(c a b))
true

=> (defn add1 [x] (+ 1 x))
#'/add1
=> (map add1 '(1 2 3))
(2 3 4)

=> (map (fn [x] (* x x)) '(1 2 3))
(1 4 9)

=> (doseq [i '(1 2 3)] (println "i = " i))
i =  1
i =  2
i =  3
nil

=> (some number? '(a b 5 c))
true

=> (some (fn [x] (and (number? x) x)) '(a b 5 c))
5

=> (every number? '(1 2 b 3))
false

=> (equal '(+ a b) (list '+ 'a 'b))
true

=> (match '(- ?x ?x) '(- (sin theta) (sin theta)))
((?x (sin theta)) (t t))

=>  (match '(- ?x ?x) '(- (sin theta) (cos theta)))
nil

=> (subst 2 'two '(two times two))
(2 times 2)

=> (sublis '((two 2) (three 3)) '(two < three))
(2 < 3)

=> (let [i 3] (+ i 1))
4