From 756345ddd407550ee41469667a66e7ce9d8eb49e Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 25 Oct 2011 14:28:49 -0400 Subject: 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. --- lib.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'lib.c') 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); -- cgit v1.2.3