From 8f3d5fd29bca41d57fbda6d9d138684b192491da Mon Sep 17 00:00:00 2001 From: admin Date: Sun, 5 Nov 2023 21:44:22 +0900 Subject: [PATCH] Implement a functional flip --- misc.scm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/misc.scm b/misc.scm index 42037a3..72c991b 100644 --- a/misc.scm +++ b/misc.scm @@ -4,6 +4,7 @@ #:export (array-map array-map-indexed + flip for-indices-in-range if-let ifn @@ -11,6 +12,12 @@ map-indexed produce-array)) +(define (flip f) + "Returns a procedure behaving as `f', but with arguments taken in reverse +order." + (lambda args + (apply f (reverse args)))) + (define-syntax if-let (syntax-rules () [(_ (x test) consequent alternate) -- 2.39.2