aboutsummaryrefslogtreecommitdiff
path: root/algebraic-structures.private.stream.scm
blob: a268841a36b50839ed0fb28ae2385ed1ae2d6c44 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
(module (algebraic-structures private stream) (<> unit fold reduce map1)
  (import scheme
          (srfi 41)
          (streams utils)
          (only (chicken base) assert))

  (define (<> xs ys) (stream-append xs ys))

  (define unit stream-null)

  (define (fold f init xs)
    (stream-fold (lambda (x acc) (f acc x))
                 init
                 xs))

  (define (reduce f xs)
    (stream-fold-one f xs))

  (define (map1 f xs)
    (stream-map f xs)))