aboutsummaryrefslogtreecommitdiff
path: root/algebraic-structures.monoid.fold.scm
blob: 037251f7ad567c06da634ce8cf2f0ba560d2e59c (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
(functor ((algebraic-structures monoid fold) (M (op unit)) (F (fold))) (fold fold-map)
  (import (except scheme length)
          (only M op unit)
          (rename (only F fold) (fold foldable:fold)))

  (define (fold x) (foldable:fold op unit x))

  (define (fold-map f x)
    (foldable:fold (lambda (x acc)
                     (op (f x) acc))
                   unit
                   x)))