-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtests
More file actions
29 lines (28 loc) · 838 Bytes
/
tests
File metadata and controls
29 lines (28 loc) · 838 Bytes
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
(+ 2 2)
(quote (testing 1 (2.0) -3.14e159))
(+ (* 2 100) (* 1 10))
(if (> 6 5) (+ 1 1) (+ 2 2))
(if (< 6 5) (+ 1 1) (+ 2 2))
(define x 3)
(x)
(+ x x)
(begin (define x 1) (set! x (+ x 1)) (+ x 1))
((lambda (x) (+ x x)) 5)
(define twice (lambda (x) (* 2 x)))
(twice 5)
(define compose (lambda (f g) (lambda (x) (f (g x)))))
((compose twice twice) 5)
(define repeat (lambda (f) (compose f f)))
((repeat twice) 5)
(define fact (lambda (n) (if (<= n 1) 1 (* n (fact (- n 1))))))
(fact 3)
(fact 20)
(define abs (lambda (n) ((if (> n 0) + -) 0 n)))
(list (abs -3) (abs 0) (abs 3))
(define x (list 0 1 2 3 4 5 6 7 8 9))
(length x)
(car (cdr x))
(define valueAt (lambda (x l) (if (> x 0) (valueAt (- x 1) (cdr l)) (car l))))
(valueAt 7 x)
(define map (lambda (f l) (if (> (length l) 0) (cons (f (car l)) (map f (cdr l))) (list ))))
(map twice x)