(assert (== 3 ((fn [a b] a) 3 2))) (defn add4 [a] (+ a 4)) (assert (== 7 (add4 3))) // testing recursion (defn fact [n] (cond (== n 0) 1 (* n (fact (- n 1))))) (assert (== 120 (fact 5))) (assert (== 3628800 (fact 10))) (defn sum [l] (cond (empty? l) 0 (+ (first l) (sum (rest l))))) (assert (== 0 (sum []))) (assert (== 6 (sum [1 2 3]))) // testing tail recursion (defn factTc [n accum] (cond (== n 0) accum (let [newn (- n 1) newaccum (* accum n)] (factTc newn newaccum)))) (assert (== 120 (factTc 5 1))) (assert (== 3628800 (factTc 10 1))) (defn sumTc [l a] (cond (empty? l) a (sumTc (rest l) (+ a (first l))))) (assert (== 0 (sumTc [] 0))) (assert (== 6 (sumTc [1 2 3] 0))) // testing anonymous dispatch ((fn [a] (assert (== a 0))) 0) // function declarations (func driveIt [a:int64 b:string] [n:int64 err:error] { (sprintf "a='%v', b='%s'\n" a b)}) //{y = (driveIt 1 2)} (assert (== (driveIt 54 "hi") "a='54', b='hi'\n")) // method declarations (method [(p *Car)] DriveAway [][s:string] (return "road-road-road"))