From 18bfa25b243653ae06956e2d029a3ccbd5d3f4e8 Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Sun, 8 Jan 2023 16:13:38 +0100 Subject: add cr --- mew.scm | 5 ++++- mew.svnwiki | 4 ++++ tests/test.mew | 6 ++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/mew.scm b/mew.scm index 0e54d91..dc5dda6 100644 --- a/mew.scm +++ b/mew.scm @@ -2,7 +2,7 @@ (export act accumulate andloc app at boolean - cmp comp cross-product + cmp comp cross-product cr dec dec! def del-at div dup empty? eof esc fail fin final for for/into fun* @@ -428,6 +428,9 @@ (else o))) o)))) + (define (cr o) + o) + (define (generic-for-each obj) (cond ((list? obj) for-each) ((vector? obj) vector-for-each) diff --git a/mew.svnwiki b/mew.svnwiki index a7f55a0..53401d4 100644 --- a/mew.svnwiki +++ b/mew.svnwiki @@ -198,6 +198,10 @@ and finally 2. Expands to a function that returns its {{}}th argument (zero indexed). Multiple arguments are returned as multiple values. +(cr ) + +The single argument identity function. Generalizes the {{c.*r}} family. + (boolean ) Return false if {{}} is {{#f}}, and true else. diff --git a/tests/test.mew b/tests/test.mew index 837edd8..633588a 100644 --- a/tests/test.mew +++ b/tests/test.mew @@ -285,6 +285,12 @@ (test 42 ((op* * 7) 2 3)) (test 42 ((op* * 2 ... 3) 7))) +(test-group "cr" + (test '(foo) (cr '(foo))) + (test 42 (cr 42)) + (test-error (cr)) + (test-error (cr 42 43))) + (test-group "rep" (test #t (void? (rep loop ()))) (test 42 (rep loop (x 27 y 5) -- cgit 1.4.1