diff options
author | Masaya Tojo <masaya@tojo.tokyo> | 2024-06-14 02:25:10 +0900 |
---|---|---|
committer | Masaya Tojo <masaya@tojo.tokyo> | 2024-06-14 02:25:10 +0900 |
commit | 326a2a122e76dd9252558551d3f5e61c4014c2c1 (patch) | |
tree | e15c4afe27f696fec5a548b6f230b38111bebf5c /algebraic-structures.monoid.fold.scm | |
parent | 9fc5da3b546ec101357fb826d7282a73cd790e83 (diff) |
Fix foldable interfaces
Diffstat (limited to 'algebraic-structures.monoid.fold.scm')
-rw-r--r-- | algebraic-structures.monoid.fold.scm | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/algebraic-structures.monoid.fold.scm b/algebraic-structures.monoid.fold.scm index b18c03c..5e176f2 100644 --- a/algebraic-structures.monoid.fold.scm +++ b/algebraic-structures.monoid.fold.scm @@ -1,4 +1,10 @@ -(functor ((algebraic-structures monoid fold) (M (<> unit)) (F (foldl foldr))) (fold) - (import scheme M F) +(functor ((algebraic-structures monoid fold) (M (<> unit)) (F (fold))) (fold) + (import scheme M (rename F (fold foldable:fold))) - (define (fold x) (foldl <> unit x))) + (define (fold x) (foldable:fold <> unit x)) + + (define (fold-map f x) + (foldable:fold (lambda (x acc) + (<> (f x) acc)) + unit + x))) |