Minilisp.pm/t/function.t

24 lines
544 B
Perl
Raw Permalink Normal View History

2021-04-10 01:02:33 +02:00
(plan 6)
2021-04-09 00:01:27 +02:00
2021-04-02 17:11:34 +02:00
(defun inc (a) (+ a 1))
(expect "inc 5 == 6" (eq (inc 5) 6))
(expect "inc 6 == 7" (eq (inc 6) 7))
2021-04-04 02:33:49 +02:00
(defun range (start end)
(if (>= start end)
'()
(cons start (range (+ start 1) end))))
(expect "range" (equal (range 1 10) '(1 2 3 4 5 6 7 8 9)))
2021-04-06 23:54:22 +02:00
(let ((a 'top))
(defun test (a) a)
(expect "function parameters do not alter context through declaration"
(equal a 'top))
(expect "parameters shadow outer bindings"
(equal (test 'param) 'param)))
2021-04-10 01:02:33 +02:00
(expect "inc"
(equal (apply + '(7 5)) 12))