Skip navigation

Scheme’s DO is generally treated with some disdain. Yet I often find myself recreating it with named LET.

So,


(let next ([i 0] [res '()])
  (if (= i 4)
    res
    (next (+ i 1) (cons i res))))

Is equivalent to:

(do ([i 0 (+ i 1)]
     [res '() (cons i res)])
  [(= i 4) res])

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: