From 326a2a122e76dd9252558551d3f5e61c4014c2c1 Mon Sep 17 00:00:00 2001 From: Masaya Tojo Date: Fri, 14 Jun 2024 02:25:10 +0900 Subject: Fix foldable interfaces --- algebraic-structures.monoid.fold.scm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'algebraic-structures.monoid.fold.scm') 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))) -- cgit v1.2.3