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