lists.zy 530 B

123456789101112131415161718192021222324
  1. (assert (== %(1 2 3) (cons 1 %(2 3))))
  2. (assert (== 1 (first %(1 2 3))))
  3. (assert (== %(2 3) (rest %(1 2 3))))
  4. (assert (== 2 (first (rest %(1 2 3)))))
  5. (let [a 3]
  6. (assert (== %(0 3) (list 0 a))))
  7. (assert (== %(1 2 4 5) (concat %(1 2) %(4 5))))
  8. (assert (== %(1 2 4 5 7 8) (concat %(1 2) %(4 5) %(7 8))))
  9. // test not-list pairs
  10. (assert (== %(1 \ 2) (cons 1 2)))
  11. (assert (== 2 (rest %(1 \ 2))))
  12. (assert (not (list? %(1 \ 2))))
  13. (assert (list? %()))
  14. (assert (list? %(1 2 3)))
  15. (assert (empty? %()))
  16. (assert (not (empty? %(1 2))))