-
Notifications
You must be signed in to change notification settings - Fork 1
/
prelude.scm
40 lines (37 loc) · 1.45 KB
/
prelude.scm
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
34
35
36
37
38
39
40
(define (not x) (if x #f #t))
(define eq? eqv?)
(define (zero? x) (if (eq? 0 x) #t #f))
(define (positive? x) (if (< 0 x) #t #f))
(define (negative? x) (if (> 0 x) #t #f))
(define (abs x) (if (positive? x) x (- 0 x)))
(define (map f l)
(if (null? l) (list)
(cons (f (car l)) (map f (cdr l))))))
(define (caar l) (car (car l)))
(define (cadr l) (car (cdr l)))
(define (cdar l) (cdr (car l)))
(define (cddr l) (cdr (cdr l)))
(define (caaar l) (car (car (car l))))
(define (caadr l) (car (car (cdr l))))
(define (cadar l) (car (cdr (car l))))
(define (caddr l) (car (cdr (cdr l))))
(define (cdaar l) (cdr (car (car l))))
(define (cdadr l) (cdr (car (cdr l))))
(define (cddar l) (cdr (cdr (car l))))
(define (cdddr l) (cdr (cdr (cdr l))))
(define (caaaar l) (car (car (car (car l)))))
(define (caaadr l) (car (car (car (cdr l)))))
(define (caadar l) (car (car (cdr (car l)))))
(define (caaddr l) (car (car (cdr (cdr l)))))
(define (cadaar l) (car (cdr (car (car l)))))
(define (cadadr l) (car (cdr (car (cdr l)))))
(define (caddar l) (car (cdr (cdr (car l)))))
(define (cadddr l) (car (cdr (cdr (cdr l)))))
(define (cdaaar l) (cdr (car (car (car l)))))
(define (cdaadr l) (cdr (car (car (cdr l)))))
(define (cdadar l) (cdr (car (cdr (car l)))))
(define (cdaddr l) (cdr (car (cdr (cdr l)))))
(define (cddaar l) (cdr (cdr (car (car l)))))
(define (cddadr l) (cdr (cdr (car (cdr l)))))
(define (cdddar l) (cdr (cdr (cdr (car l)))))
(define (cddddr l) (cdr (cdr (cdr (cdr l)))))