|
SketchyLISP Reference |
Copyright (C) 2007 Nils M Holm |
| <<[intersection] | [Index] | [last]>> |
Conformance: SketchyLISP Extension
Purpose: Generate sequences of numbers.
Arguments:
l - lower limit of sequence
h - upper limit of sequence
Model:
(define (iota l h)
(cond ((= l h) (list l))
(else (cons l (iota (+ l 1) h)))))
Implementation:
(define (iota l h)
(letrec
((j
(lambda (x r)
(cond ((= x l) (cons l r))
(else (j (- x 1) (cons x r)))))))
(cond ((> l h)
(bottom '(iota: bad range)))
(else (j h '())))))
Example:
(iota 1 10) => (1 2 3 4 5 6 7 8 9 10)
| <<[intersection] | [Index] | [last]>> |