diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-03-12 20:40:03 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-03-12 20:40:03 -0700 |
commit | e39f3fcc0520ce0d93082a8b8e87187eb38efd48 (patch) | |
tree | 35c82a812f230e08405eb365a7fec4badc42af3f /lib.c | |
parent | df45e73d23d6871ce0ca415e009bf1bd2a520804 (diff) | |
download | txr-e39f3fcc0520ce0d93082a8b8e87187eb38efd48.tar.gz txr-e39f3fcc0520ce0d93082a8b8e87187eb38efd48.tar.bz2 txr-e39f3fcc0520ce0d93082a8b8e87187eb38efd48.zip |
New functions starts-with and ends-with.
* eval.c (eval_init): Register starts-with and ends-with
intrinsics.
* lib.c (starts_with, ends_with): New functions.
* lib.c (starts_with, ends_with): Declared.
* txr.1: Documented.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -8565,6 +8565,18 @@ val rmismatch(val left, val right, val testfun_in, val keyfun_in) left, right, nao); } +val starts_with(val little, val big, val testfun, val keyfun) +{ + val mm = mismatch(little, big, testfun, keyfun); + return tnil(!mm || eql(mm, length(little))); +} + +val ends_with(val little, val big, val testfun, val keyfun) +{ + val mm = rmismatch(little, big, testfun, keyfun); + return tnil(!mm || eql(pred(neg(mm)), length(little))); +} + static val take_list_fun(val env, val lcons) { cons_bind (list, count, env); |