Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,4 @@
|
|||
(do ((i 2 (+ i 2))) ; list of variables, initials and steps -- you can iterate over several at once
|
||||
((>= i 9)) ; exit condition
|
||||
(display i) ; body
|
||||
(newline))
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
(let loop ((i 2)) ; function name, parameters and starting values
|
||||
(cond ((< i 9)
|
||||
(display i)
|
||||
(newline)
|
||||
(loop (+ i 2)))))) ; tail-recursive call, won't create a new stack frame
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
(define (for-loop start end step func)
|
||||
(let loop ((i start))
|
||||
(cond ((< i end)
|
||||
(func i)
|
||||
(loop (+ i step))))))
|
||||
|
||||
(for-loop 2 9 2
|
||||
(lambda (i)
|
||||
(display i)
|
||||
(newline)))
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
(define-syntax for-loop
|
||||
(syntax-rules ()
|
||||
((for-loop index start end step body ...)
|
||||
(let ((evaluated-end end) (evaluated-step step))
|
||||
(let loop ((i start))
|
||||
(if (< i evaluated-end)
|
||||
((lambda (index) body ... (loop (+ i evaluated-step))) i)))))))
|
||||
|
||||
(for-loop i 2 9 2
|
||||
(display i)
|
||||
(newline))
|
||||
Loading…
Add table
Add a link
Reference in a new issue