Created
July 29, 2018 13:59
-
-
Save blippy/f92864304abec86a33062f3f202cbbd4 to your computer and use it in GitHub Desktop.
for ... next BASIC type loop in scheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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