Fixed PR 7650.
iota now uses (+ start (* n step)) to calculate the elements, instead of successive subtractions. svn: r6025
This commit is contained in:
parent
940d100b2d
commit
a5550a69da
|
@ -102,11 +102,14 @@
|
||||||
(check-arg integer? count 'iota)
|
(check-arg integer? count 'iota)
|
||||||
(check-arg number? start 'iota)
|
(check-arg number? start 'iota)
|
||||||
(check-arg number? step 'iota)
|
(check-arg number? step 'iota)
|
||||||
(let ((last-val (+ start (* (- count 1) step))))
|
(unless (or (zero? count) (positive? count))
|
||||||
(do ((count count (- count 1))
|
(error 'iota "count expected to be non-negative, got: ~a" count))
|
||||||
(val last-val (- val step))
|
(let loop ([n 0])
|
||||||
(ans '() (cons val ans)))
|
(cond
|
||||||
((<= count 0) ans)))))
|
[(= n count) '()]
|
||||||
|
[else (cons (+ start (* n step))
|
||||||
|
(loop (add1 n)))]))))
|
||||||
|
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user