Minilisp.pm/t/lists.t

12 lines
512 B
Perl
Raw Normal View History

2021-04-02 20:01:43 +02:00
(let ((lst (list 1 2 3)))
(write "# lst = ") (write-line lst)
(expect "Length of list is 3" (= (length lst) 3))
(expect "First element is 1" (= (first lst) 1))
(expect "Second element is 2" (= (second lst) 2))
(expect "Third element is 3" (= (nth 2 lst) 3))
2021-04-02 20:18:42 +02:00
(expect "Equal to itself" (equal lst lst))
(expect "Equal to identical list" (equal lst (list 1 2 3)))
(expect "Reduce with +" (= (reduce + lst) 6))
(expect "Map doubling values" (equal (map (lambda (x) (* x 2)) lst) (list 2 4 6)))
2021-04-02 20:01:43 +02:00
)