Add in map from underlying scheme for Exercise 4.14

This doesn't work, as described in the question, so back out of this branch.
This commit is contained in:
Oliver Payne 2023-04-27 23:06:44 +01:00
parent 543a06efa2
commit b3b88a3581
1 changed files with 16 additions and 1 deletions

View File

@ -607,6 +607,7 @@
(list '/ /)
(list '< <)
(list '> >)
(list 'map map)
;; more primitives
))
@ -720,6 +721,20 @@
;; (map fib '(1 2 3 4 5 6 7 8 9 10)) -> (1 1 2 3 5 8 13 21 34 55)
)
;; Exercise 4.14
;; Using map from the underlying interpreter doesn't work, because the
;; interpreter and interpreted language have different representations
;; of procedures. If we use the underlying map and pass it a
;; procedure from the interpreted language, it just sees a list
;; '(procedure ...), which is just a list of symbols in the underlying
;; lisp.
;; map definition
(define (my-map f x)
(if (null? x)
'()
(cons (f (car x))
(my-map f (cdr x)))))