iota from srfi-1 added by sjamaan 2 days ago

(define (iota count . maybe-start+step)
;  (check-arg integer? count iota)
  (##sys#check-number count 'iota)
  (if (< count 0) (##sys#error 'iota "Negative step count" iota count))
  (let-optionals maybe-start+step ((start 0) ; Olin, I'm tired of fixing your stupid bugs - why didn't
				   (step 1) ) ; you use your own macros, then?
    (##sys#check-number start 'iota)
    (##sys#check-number step 'iota)
;    (check-arg number? start iota)
;    (check-arg number? step iota)
    (let ((last-val (+ start (* (- count 1) step))))
      (do ((count count (- count 1))
	   (val last-val (- val step))
	   (ans '() (cons val ans)))
	  ((<= count 0)  ans)))))