[ prog / sol / mona ]

prog


Do you even Scheme?

33 2020-09-16 13:02

>>30
sure, I think all but the last would be amenable to letrec, for the last, it's not even clear what it means.

;; From SICP Section 4.16
(define (f x)
  (define (even? n) (if (= n 0) #t (odd (- n 1))))
  (define (odd? n) (if (= n 0) #t (even? (- n 1))))
  <rest of body of f>)

(define (solve f y0 dt)
  (define y (integral (delay dy) y0 dt))
  (define dy (stream-map f y))
  y)

(let ((a 1))
  (define (f x)
    (define b (+ a x))
    (define a 5)
    (+ a b))
  (f 10))
47


VIP:

do not edit these