summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2011-10-25 14:28:49 -0400
committerKaz Kylheku <kaz@kylheku.com>2011-10-25 14:28:49 -0400
commit756345ddd407550ee41469667a66e7ce9d8eb49e (patch)
treefa29d7e942a344147329a78c004d1097ca9072cf /lib.c
parentbdca604f10ffdbde56c68ca30b4adbee0f10818e (diff)
downloadtxr-756345ddd407550ee41469667a66e7ce9d8eb49e.tar.gz
txr-756345ddd407550ee41469667a66e7ce9d8eb49e.tar.bz2
txr-756345ddd407550ee41469667a66e7ce9d8eb49e.zip
Shorthand for filters which map multiple texts to a common
replacement text. * filter.c (build_filter_from_list): Allow tuples to denote multiple keys mapping to the same value. * lib.c (do_curry_123_2, do_curry_123_1): New static functions. (curry_123_2, curry_123_1): New functions. * lib.h (curry_123_2, curry_123_1): New functions declared. * match.c (v_deffilter): Allow tuples of strings rather than just pairs. * txr.1: Updated.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index d5a6634a..6af8dd58 100644
--- a/lib.c
+++ b/lib.c
@@ -1598,6 +1598,16 @@ val curry_12_1(val fun2, val arg2)
return func_f1(cons(fun2, arg2), do_curry_12_1);
}
+static val do_curry_123_3(val fcons, val arg3)
+{
+ return funcall3(car(fcons), car(cdr(fcons)), cdr(cdr(fcons)), arg3);
+}
+
+val curry_123_3(val fun3, val arg1, val arg2)
+{
+ return func_f1(cons(fun3, cons(arg1, arg2)), do_curry_123_3);
+}
+
static val do_curry_123_2(val fcons, val arg2)
{
return funcall3(car(fcons), car(cdr(fcons)), arg2, cdr(cdr(fcons)));
@@ -1608,6 +1618,16 @@ val curry_123_2(val fun3, val arg1, val arg3)
return func_f1(cons(fun3, cons(arg1, arg3)), do_curry_123_2);
}
+static val do_curry_123_1(val fcons, val arg1)
+{
+ return funcall3(car(fcons), arg1, car(cdr(fcons)), cdr(cdr(fcons)));
+}
+
+val curry_123_1(val fun3, val arg2, val arg3)
+{
+ return func_f1(cons(fun3, cons(arg2, arg3)), do_curry_123_1);
+}
+
static val do_curry_123_23(val fcons, val arg2, val arg3)
{
return funcall3(car(fcons), cdr(fcons), arg2, arg3);