- How to recur on a list of atoms, a number and an S-expression | 23 64 83
- Cons to build | 37
- Typical element, cons & recur | 45
- Change >= 1 arg closer to termination & test | 57 65 84
- +, X & cons; test 0,1,() | 67
- When to simplify | 94
- Subparts: sublists & subexpressions | 103
- Abstract reps w/ funcs | 107
- Abstract patterns w/ funcs | 134
- Funcs to collect > 1 value | 140
- The Five Rules
- Car 5
- Cdr 7
- Cons 9
- Null? 10
- Eq? 12
- Dimensions of functions
- On lats (lists of atoms - flat), numbers or S-expression (hierarchy)
- Test, insert (L/R), replace, remove
- Straight/single function, abstracted/generalized
- Data types and structures
- atom 3
- number
- list 3 & 4
- S-expression 3 & 4
- lat (list of atoms) 15
- set 111
- pair 117 & 118
- rel 119
- fun 120
- fullfun/one-to-one 121 & 122
- entrie 175
- table (environment) 176
- Other
- Collector/Continuation 137
- End
- End
(define atom?
(lambda (x)
(and (not (pair? x)) (not (null? x)))))
(define lat?
(lambda (l)
(cond
((null? l) #t)
((atom? (car l)) (lat? (cdr l)))
(else #f))))
(define multirember&co
(lambda (a lat col)
(cond
((null? lat)
(col (quote()) (quote())))
((eq? (car lat) a)
(multirember&co a
(cdr lat)
(lambda (newlat seen)
(col newlat
(cons (car lat) seen)))))
(else
(multirember&co a
(cdr lat)
(lambda (newlat seen)
(col (cons (car lat) newlat)
seen)))))))
(define a-friend
(lambda (x y)
(null? y)))
(multirember&co (quote tuna) (quote ()) a-friend)(multirember&co (quote tuna) (quote (tuna)) a-friend)
(define last-friend
(lambda (x y)
(length x)))
(multirember&co (quote tuna) (quote (stawberries tuna and swordfish)) last-friend)