[ prog / sol / mona ]

prog


Sussman hates Scheme

7 2022-06-14 21:17

Someone tell the Sussman that you can give names to the "connections" in Scheme:

(define (heron-step x g)
  (let* ((x/g (/ x g))
         (x/g+g (+ g x/g))
         (two 2))
    (/ x/g+g two)))

Or even like this, using SRFI-8:

(define (heron-step x g)
  (receive (x/g) (/ x g)
    (receive (x/g+g) (+ g x/g)
      (/ x/g+g 2))))
14


VIP:

do not edit these