aboutsummaryrefslogtreecommitdiff
path: root/algebraic-structures.private.stream.scm
blob: b966a9412eaa5f26813cf780ef23d599c5a484ec (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) (op unit fold reduce map1)
  (import scheme
          (srfi 41)
          (streams utils)
          (only (chicken base) assert))

  (define (op 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)))