From 3ed8f24277ebb6b814dff180c0d8661f0e14b4fd Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Wed, 16 Dec 2020 23:21:33 +0100 Subject: [PATCH] utils.rkt: Replace multi-compose by the implementation by Sorawee. --- utils.rkt | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/utils.rkt b/utils.rkt index 4a78076..613ddea 100644 --- a/utils.rkt +++ b/utils.rkt @@ -1,7 +1,6 @@ #lang typed/racket -(require (for-syntax syntax/parse racket/list - (only-in racket/match match-define))) +(require (for-syntax syntax/parse racket/list)) (provide Variable VariableMapping GeneralPair eval-with eval1-with @@ -148,13 +147,12 @@ (λ (x) (f1 (f2 (f3 (f4 x)))))) (define-syntax (multi-compose stx) + ;; Implementation by Sorawee Porncharoenwase. (syntax-parse stx - [(_ f1 f2 funcs ...) - (match-define (list fn fn-1 fs ...) - (reverse (cons #'f1 (cons #'f2 (syntax->list #'(funcs ...)))))) - (datum->syntax stx (for/fold ([sexp `(compose ,fn-1 ,fn)]) - ([f (in-list fs)]) - `(compose ,f ,sexp)))])) + [(_ f:expr g:expr) + #'(compose f g)] + [(_ f:expr funcs:expr ...) + #'(compose f (multi-compose funcs ...))])) (module+ test (check-equal? ((multi-compose add1