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

  (define (fold x) (foldable:fold <> unit x))

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