Skip to content
This repository has been archived by the owner on Mar 21, 2023. It is now read-only.

airt/lazy-sequence

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lazy-sequence

Build Status

exercises of lazy evaluation

usage

(define natural-numbers
  (lazy-iterate add1 0))

(lazy->list
  (lazy-take 5
    (lazy-drop 50 natural-numbers)))
; => (range 50 55)

(define primes
  (letrec ((sieve
    (λ (xs) (let ((x (lazy-car xs)))
      (lazy-cons x
        (sieve
          (lazy-filter
            (λ (y)
              (positive? (remainder y x)))
            xs)))))))
    (sieve (lazy-iterate add1 2))))

(lazy->list
  (lazy-take 5
    (lazy-drop 50 primes)))
; => '(233 239 241 251 257)

api

;;; list operations ;;;

lazy?
lazy->list
list->lazy

lazy-cons
lazy-car
lazy-cdr
lazy-caar
lazy-cdar

lazy-ref
lazy-range
lazy-append

lazy-foldr
lazy-filter
lazy-map

;;; special folds ;;;

lazy-and
lazy-or
lazy-any
lazy-all
lazy-concat
lazy-concat-map

;;; infinite lists ;;;

lazy-iterate
lazy-repeat
lazy-replicate
lazy-cycle

;;; sublists ;;;

lazy-take
lazy-drop
lazy-take-while
lazy-drop-while
lazy-split-at
lazy-span

;;; zipping lists ;;;

lazy-zip
lazy-zip-with

license

BSD-3-Clause

About

exercises of lazy evaluation

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages