1 ;; -----------------------------------------------------
4 ;; Testing list functions
21 (if (> (count (list 1 2 3)) 3) "yes" "no")
23 (if (>= (count (list 1 2 3)) 3) "yes" "no")
32 (if true (+ 1 7) (+ 1 8))
34 (if false (+ 1 7) (+ 1 8))
50 ;; Testing 1-way if form
59 ;; Testing basic conditionals
126 (= (list 1 2) (list 1 2))
142 ;; Testing builtin and user defined functions
145 ( (fn* (a b) (+ b a)) 3 4)
150 ( (fn* (f x) (f x)) (fn* (a) (+ 1 a)) 7)
155 ( ( (fn* (a) (fn* (b) (+ a b))) 5) 7)
158 (def! gen-plus5 (fn* () (fn* (b) (+ 5 b))))
159 (def! plus5 (gen-plus5))
163 (def! gen-plusX (fn* (x) (fn* (b) (+ x b))))
164 (def! plus7 (gen-plusX 7))
169 (do (prn "prn output1"))
172 (do (prn "prn output2") 7)
175 (do (prn "prn output1") (prn "prn output2") (+ 1 2))
180 (do (def! a 6) 7 (+ a 8))
185 ;; Testing special form case-sensitivity
186 (def! DO (fn* (a) 7))
190 ;; Testing recursive sumdown function
191 (def! sumdown (fn* (N) (if (> N 0) (+ N (sumdown (- N 1))) 0)))
200 ;; Testing recursive fibonacci function
201 (def! fib (fn* (N) (if (= N 0) 1 (if (= N 1) 1 (+ (fib (- N 1)) (fib (- N 2)))))))
208 ;;; Too slow for bash, erlang, make and miniMAL
215 ;; -------- Deferrable Functionality --------
217 ;; Testing variable length arguments
219 ( (fn* (& more) (count more)) 1 2 3)
221 ( (fn* (& more) (list? more)) 1 2 3)
223 ( (fn* (& more) (count more)) 1)
225 ( (fn* (& more) (count more)) )
227 ( (fn* (& more) (list? more)) )
229 ( (fn* (a & more) (count more)) 1 2 3)
231 ( (fn* (a & more) (count more)) 1)
233 ( (fn* (a & more) (list? more)) 1)
237 ;; Testing language defined not function
248 ;; -----------------------------------------------------
250 ;; Testing string quoting
281 (pr-str "abc def" "ghi jkl")
282 ;=>"\"abc def\" \"ghi jkl\""
287 (pr-str (list 1 2 "abc" "\"") "def")
288 ;=>"(1 2 \"abc\" \"\\\"\") \"def\""
290 (pr-str "abc\ndef\nghi")
291 ;=>"\"abc\\ndef\\nghi\""
293 (pr-str "abc\\def\\ghi")
294 ;=>"\"abc\\\\def\\\\ghi\""
316 (str "abc def" "ghi jkl")
319 (str "abc\ndef\nghi")
322 (str "abc\\def\\ghi")
325 (str (list 1 2 "abc" "\"") "def")
344 (prn "abc def" "ghi jkl")
345 ; "abc def" "ghi jkl"
351 (prn "abc\ndef\nghi")
355 (prn "abc\\def\\ghi")
359 (prn (list 1 2 "abc" "\"") "def")
360 ; (1 2 "abc" "\"") "def"
377 (println "abc def" "ghi jkl")
384 (println "abc\ndef\nghi")
390 (println "abc\\def\\ghi")
394 (println (list 1 2 "abc" "\"") "def")
400 ;; -------- Optional Functionality --------
410 ;; Testing vector truthiness
414 ;; Testing vector printing
415 (pr-str [1 2 "abc" "\""] "def")
416 ;=>"[1 2 \"abc\" \"\\\"\"] \"def\""
421 (str [1 2 "abc" "\""] "def")
428 ;; Testing vector functions
438 ;; Testing vector equality
458 ;; Testing vector parameter lists
461 ( (fn* [f x] (f x)) (fn* [a] (+ 1 a)) 7)
464 ;; Nested vector/list equality
465 (= [(list)] (list []))
467 (= [1 2 (list 3 4 [5 6])] (list 1 2 [3 4 (list 5 6)]))