From 479a5ef7f1fe3b351ed313c41bbcc6d4b39ef3c6 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sun, 20 May 2018 13:18:36 +0200 Subject: [PATCH] mes: Add const. * module/mes/scm.mes (const): New function. * tests/scm.test ("const"): Test it. --- module/mes/scm.mes | 4 ++++ tests/scm.test | 3 +++ 2 files changed, 7 insertions(+) diff --git a/module/mes/scm.mes b/module/mes/scm.mes index 9beac54b..9bd53581 100644 --- a/module/mes/scm.mes +++ b/module/mes/scm.mes @@ -351,3 +351,7 @@ (define (negate proc) (lambda args (not (apply proc args)))) + +(define (const . rest) + (lambda (. _) + (car rest))) diff --git a/tests/scm.test b/tests/scm.test index 7254d184..98055a9f 100755 --- a/tests/scm.test +++ b/tests/scm.test @@ -159,4 +159,7 @@ exit $? (pass-if-equal "octal" 65 #o101) (pass-if-equal "hex" 257 #x101) +(pass-if-equal "negate" #t ((negate eq?) 0 1)) +(pass-if-equal "const" 42 ((const 42) 1 2 3 4)) + (result 'report)