diff --git a/module/mes/scm.mes b/module/mes/scm.mes index 56906640..e04e982c 100644 --- a/module/mes/scm.mes +++ b/module/mes/scm.mes @@ -183,6 +183,11 @@ (define (delq x lst) (filter (lambda (e) (not (eq? e x))) lst)) +(define (compose proc . rest) + (if (null? rest) proc + (lambda args + (proc (apply (apply compose rest) args))))) + ;; Vector (define (vector . rest) (list->vector rest)) diff --git a/tests/scm.test b/tests/scm.test index 2f444255..904c4b10 100755 --- a/tests/scm.test +++ b/tests/scm.test @@ -9,7 +9,7 @@ exit $? ;;; -*-scheme-*- ;;; Mes --- Maxwell Equations of Software -;;; Copyright © 2016 Jan Nieuwenhuizen +;;; Copyright © 2016,2017 Jan Nieuwenhuizen ;;; ;;; This file is part of Mes. ;;; @@ -136,4 +136,6 @@ exit $? (pass-if "char-alphabetic?" (seq? (char-alphabetic? #\a) #t)) (pass-if "char-alphabetic? 2" (seq? (char-alphabetic? #\[) #f)) +(pass-if-equal "compose" 1 ((compose car cdr car) '((0 1 2)))) + (result 'report)