Commits

Anonymous committed 5320e69

Make lazy-numbers more efficient

Comments (0)

Files changed (1)

               (lazy-take (- n 1) (lazy-tail seq))))))
 
 (define (lazy-drop n seq)
-
-  ;; (lazy-seq
-  ;;   (let loop ((n n) (seq seq))
-  ;;     (if (or (zero? n) (lazy-null? seq))
-  ;;         seq
-  ;;         (loop (- n 1) (lazy-tail seq)))))
-
   (lazy-seq
     (if (or (zero? n) (lazy-null? seq))
         seq
         (lazy-drop (- n 1) (lazy-tail seq)))))
 
 (define (lazy-numbers #!key (step 1) (start 0) count)
-  (lazy-seq
-    (if (and count (zero? count))
-        '()
-        (cons start
-              (lazy-numbers count: (and count (- count 1))
-                            start: (+ start step)
-                            step:  step)))))
+  (let loop ((count count) (start start) (step step))
+    (lazy-seq
+      (if (and count (zero? count))
+          '()
+          (cons start
+                (loop (and count (- count 1))
+                      (+ start step)
+                      step))))))
 
 (define (lazy-map proc . seqs)
   (lazy-seq