aboutsummaryrefslogtreecommitdiff
path: root/algebraic-structures.monoid.fold.scm
blob: bb74e4a1e549a6f5bdfb2bafb0c4350a29ca7338 (about) (plain)
1
2
3
4
5
6
7
8
9
10
(functor ((algebraic-structures monoid fold) (M (<> unit)) (F (fold))) (fold fold-map)
  (import scheme M (rename F (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)))