1 ;; -----------------------------------------------------
4 ;; Testing list functions
21 (if (> (count (list 1 2 3)) 3) 89 78)
23 (if (>= (count (list 1 2 3)) 3) 89 78)
34 (if true (+ 1 7) (+ 1 8))
36 (if false (+ 1 7) (+ 1 8))
50 ;; Testing 1-way if form
61 ;; Testing basic conditionals
122 (= (list 1 2) (list 1 2))
132 (= (list nil) (list))
136 ;; Testing builtin and user defined functions
139 ( (fn* (a b) (+ b a)) 3 4)
144 ( (fn* (f x) (f x)) (fn* (a) (+ 1 a)) 7)
149 ( ( (fn* (a) (fn* (b) (+ a b))) 5) 7)
152 (def! gen-plus5 (fn* () (fn* (b) (+ 5 b))))
153 (def! plus5 (gen-plus5))
157 (def! gen-plusX (fn* (x) (fn* (b) (+ x b))))
158 (def! plus7 (gen-plusX 7))
169 (do (prn 101) (prn 102) (+ 1 2))
174 (do (def! a 6) 7 (+ a 8))
179 ;; Testing special form case-sensitivity
180 (def! DO (fn* (a) 7))
184 ;; Testing recursive sumdown function
185 (def! sumdown (fn* (N) (if (> N 0) (+ N (sumdown (- N 1))) 0)))
194 ;; Testing recursive fibonacci function
195 (def! fib (fn* (N) (if (= N 0) 1 (if (= N 1) 1 (+ (fib (- N 1)) (fib (- N 2)))))))
204 ;; Testing recursive function in environment.
205 (let* (cst (fn* (n) (if (= n 0) nil (cst (- n 1))))) (cst 1))
207 (let* (f (fn* (n) (if (= n 0) 0 (g (- n 1)))) g (fn* (n) (f n))) (f 2))
213 ;; -------- Deferrable Functionality --------
215 ;; Testing if on strings
220 ;; Testing string equality
239 ;; Testing variable length arguments
241 ( (fn* (& more) (count more)) 1 2 3)
243 ( (fn* (& more) (list? more)) 1 2 3)
245 ( (fn* (& more) (count more)) 1)
247 ( (fn* (& more) (count more)) )
249 ( (fn* (& more) (list? more)) )
251 ( (fn* (a & more) (count more)) 1 2 3)
253 ( (fn* (a & more) (count more)) 1)
255 ( (fn* (a & more) (list? more)) 1)
259 ;; Testing language defined not function
272 ;; -----------------------------------------------------
274 ;; Testing string quoting
308 (pr-str "abc def" "ghi jkl")
309 ;=>"\"abc def\" \"ghi jkl\""
314 (pr-str (list 1 2 "abc" "\"") "def")
315 ;=>"(1 2 \"abc\" \"\\\"\") \"def\""
317 (pr-str "abc\ndef\nghi")
318 ;=>"\"abc\\ndef\\nghi\""
320 (pr-str "abc\\def\\ghi")
321 ;=>"\"abc\\\\def\\\\ghi\""
343 (str "abc def" "ghi jkl")
346 (str "abc\ndef\nghi")
349 (str "abc\\def\\ghi")
352 (str (list 1 2 "abc" "\"") "def")
371 (prn "abc def" "ghi jkl")
372 ;/"abc def" "ghi jkl"
378 (prn "abc\ndef\nghi")
382 (prn "abc\\def\\ghi")
383 ;/"abc\\\\def\\\\ghi"
386 (prn (list 1 2 "abc" "\"") "def")
387 ;/\(1 2 "abc" "\\""\) "def"
404 (println "abc def" "ghi jkl")
411 (println "abc\ndef\nghi")
417 (println "abc\\def\\ghi")
421 (println (list 1 2 "abc" "\"") "def")
433 (= (list :abc) (list :abc))
436 ;; Testing vector truthiness
440 ;; Testing vector printing
441 (pr-str [1 2 "abc" "\""] "def")
442 ;=>"[1 2 \"abc\" \"\\\"\"] \"def\""
447 (str [1 2 "abc" "\""] "def")
454 ;; Testing vector functions
464 ;; Testing vector equality
486 ;; Testing vector parameter lists
489 ( (fn* [f x] (f x)) (fn* [a] (+ 1 a)) 7)
492 ;; Nested vector/list equality
493 (= [(list)] (list []))
495 (= [1 2 (list 3 4 [5 6])] (list 1 2 [3 4 (list 5 6)]))