aboutsummaryrefslogtreecommitdiff
path: root/src/lisp/test.lisp
blob: 5eb1aaad9600b36d0b1c690ff1350ac220e9653c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
(assert-eq
  (range 0 10)
  '(0 1 2 3 4 5 6 7 8 9))

(assert-eq
  (for (i (range 0 10)) (+ i 1))
  (map (lambda (x) (+ x 1)) (range 0 10)))

(assert (and #t #t))
(assert (or #f #t))
(assert (not #f))

(assert-eq
  (for (i '(1 2 3)) (for (j '(1 2 3)) (+ i j)))
  (list '(2 3 4) '(3 4 5) '(4 5 6)))

(assert-eq
  ((lambda (x) x) 2)
  2)

(define x 2)
(define y 5)
(set! x 3)
(assert-eq x 3)

(define (square-x x)
  (let [(y x)]
    (begin
      (set! y (* x x))
      y)))

(assert-eq (square-x 2) 4)
(assert-eq y 5)