Skip to content

Instantly share code, notes, and snippets.

@blippy
Created July 29, 2018 13:59
Show Gist options
  • Save blippy/f92864304abec86a33062f3f202cbbd4 to your computer and use it in GitHub Desktop.
Save blippy/f92864304abec86a33062f3f202cbbd4 to your computer and use it in GitHub Desktop.
for ... next BASIC type loop in scheme
#lang racket
(define-syntax for-next
(syntax-rules ()
((_ var lo hi body ...)
(let loop ((var lo))
body ...
(when (< var hi)
(loop (+ 1 var)))))))
;; Example
(for-next i 2 5
(displayln i))
;; outputs 2 3 4 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment