From 2b8f36bfa9572ae0ef968bdb201d8a693d8dd97c Mon Sep 17 00:00:00 2001 From: anemofilia Date: Sun, 27 Aug 2023 19:11:01 -0300 Subject: [PATCH] feat: add flip and swap combinators to (radix combinators) module --- modules/radix/combinators.scm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/radix/combinators.scm b/modules/radix/combinators.scm index 4332d17..b110866 100644 --- a/modules/radix/combinators.scm +++ b/modules/radix/combinators.scm @@ -6,7 +6,9 @@ any-of conjoin disjoin - inclusive-disjoin)) + inclusive-disjoin + flip + swap)) (define ((all-of pred) lst) (null? (filter (negate pred) lst))) @@ -37,3 +39,8 @@ ((not (apply head-pred args)) (loop tail-preds)) (else #f))))) +(define ((flip proc) . args) + (apply proc (reverse args))) + +(define ((swap proc) arg1 arg2 . args) + (apply proc arg2 arg1 args))