From: Chris Hanson Date: Tue, 24 Jan 2017 22:10:30 +0000 (-0800) Subject: Implement fix:iota. X-Git-Tag: mit-scheme-pucked-9.2.12~227^2~91 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=a2c3d3c8380c26c615b7e6a9c67ab467e55d7bfd;p=mit-scheme.git Implement fix:iota. --- diff --git a/src/runtime/fixart.scm b/src/runtime/fixart.scm index 75d183650..fecafb7a9 100644 --- a/src/runtime/fixart.scm +++ b/src/runtime/fixart.scm @@ -118,6 +118,30 @@ USA. (if (not (fix:fixnum? n)) (error "Unable to compute smallest fixnum:" n)) n))))) + +(define (fix:iota count #!optional start step) + (guarantee index-fixnum? count 'fix:iota) + (let ((start + (if (default-object? start) + 0 + (begin + (guarantee fix:fixnum? start 'fix:iota) + start))) + (step + (if (default-object? step) + 1 + (begin + (guarantee fix:fixnum? step 'fix:iota) + step)))) + (let loop + ((index (fix:- count 1)) + (value (fix:+ start (fix:* step (fix:- count 1)))) + (result '())) + (if (fix:>= index 0) + (loop (fix:- index 1) + (fix:- value step) + (cons value result)) + result)))) ;;;; Flonums