diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2011-10-25 14:28:49 -0400 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2011-10-25 14:28:49 -0400 |
commit | 756345ddd407550ee41469667a66e7ce9d8eb49e (patch) | |
tree | fa29d7e942a344147329a78c004d1097ca9072cf /match.c | |
parent | bdca604f10ffdbde56c68ca30b4adbee0f10818e (diff) | |
download | txr-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 'match.c')
-rw-r--r-- | match.c | 14 |
1 files changed, 5 insertions, 9 deletions
@@ -2555,18 +2555,14 @@ static val v_deffilter(match_files_ctx c, match_files_ctx *cout) if (!all_satisfy(table, andf(func_n1(listp), chain(func_n1(length), - curry_12_2(func_n2(eq), two), - nao), - chain(func_n1(first), - func_n1(stringp), - nao), - chain(func_n1(second), - func_n1(stringp), - nao), + curry_12_1(func_n2(ge), two), nao), + chain(func_n1(rest), + curry_123_1(func_n3(all_satisfy), + func_n1(stringp), nil), nao), nao), nil)) sem_error(spec_linenum, - lit("deffilter arguments must be string pairs"), + lit("deffilter arguments must be lists of at least two strings"), nao); register_filter(sym, table); /* TODO: warn about replaced filter. */ |