1 ;; -----------------------------------------------------
4 ;; Testing list functions
17 (if (> (count (list 1 2 3)) 3) "yes" "no")
19 (if (>= (count (list 1 2 3)) 3) "yes" "no")
28 (if true (+ 1 7) (+ 1 8))
30 (if false (+ 1 7) (+ 1 8))
44 ;; Testing 1-way if form
53 ;; Testing basic conditionals
112 (= (list 1 2) (list 1 2))
128 ;; Testing builtin and user defined functions
131 ( (fn* (a b) (+ b a)) 3 4)
136 ( (fn* (f x) (f x)) (fn* (a) (+ 1 a)) 7)
141 ( ( (fn* (a) (fn* (b) (+ a b))) 5) 7)
144 (def! gen-plus5 (fn* () (fn* (b) (+ 5 b))))
145 (def! plus5 (gen-plus5))
149 (def! gen-plusX (fn* (x) (fn* (b) (+ x b))))
150 (def! plus7 (gen-plusX 7))
155 ;; Testing variable length arguments
157 ( (fn* (& more) (count more)) 1 2 3)
159 ( (fn* (& more) (count more)) 1)
161 ( (fn* (& more) (count more)) )
163 ( (fn* (a & more) (count more)) 1 2 3)
165 ( (fn* (a & more) (count more)) 1)
169 ;; Testing language defined not function
181 (do (prn "prn output1"))
184 (do (prn "prn output2") 7)
187 (do (prn "prn output1") (prn "prn output2") (+ 1 2))
192 (do (def! a 6) 7 (+ a 8))
198 ;; Testing recursive sumdown function
199 (def! sumdown (fn* (N) (if (> N 0) (+ N (sumdown (- N 1))) 0)))
208 ;; Testing recursive fibonacci function
209 (def! fib (fn* (N) (if (= N 0) 1 (if (= N 1) 1 (+ (fib (- N 1)) (fib (- N 2)))))))
219 ;; -----------------------------------------------------
221 ;; Testing string quoting
247 (pr-str "abc def" "ghi jkl")
248 ;=>"\"abc def\" \"ghi jkl\""
253 (pr-str (list 1 2 "abc" "\"") "def")
254 ;=>"(1 2 \"abc\" \"\\\"\") \"def\""
274 (str "abc def" "ghi jkl")
277 ;;; TODO: get this working properly
278 ;;;(str (list 1 2 "abc" "\"") "def")
279 ;;;;=>"(1 2 \"abc\" \"\\\"\")def"
295 (prn "abc def" "ghi jkl")
296 ; "abc def" "ghi jkl"
302 (prn (list 1 2 "abc" "\"") "def")
303 ; (1 2 "abc" "\"") "def"
320 (println "abc def" "ghi jkl")
327 (println (list 1 2 "abc" "\"") "def")
332 ;; -------- Optional Functionality --------
334 ;; Testing vector truthiness
338 ;; Testing vector equality
356 ;; Testing vector parameter lists
359 ( (fn* [f x] (f x)) (fn* [a] (+ 1 a)) 7)