diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-02-24 20:14:17 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-02-24 20:14:17 -0800 |
commit | 40768ab0200b1017e0cb9e1f799fced830074519 (patch) | |
tree | fdfb767b574d1d6cd07fb882c82c8ff67d3453ad /lib.c | |
parent | 37cfe995711604880217b1e07ee1274819a2b926 (diff) | |
download | txr-40768ab0200b1017e0cb9e1f799fced830074519.tar.gz txr-40768ab0200b1017e0cb9e1f799fced830074519.tar.bz2 txr-40768ab0200b1017e0cb9e1f799fced830074519.zip |
bracket: new function.
* eval.c (eval_init): Register bracket intrinsic.
* lib.c (bracket): New function.
* lib.h (bracket): Declared.
* txr.1: Documented.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -3586,6 +3586,19 @@ static val rexpt(val right, val left) return expt(left, right); } +val bracket(val larg, struct args *args) +{ + cnum index = 0; + + while (args_more(args, index)) { + val rarg = args_get(args, &index); + if (less(larg, rarg)) + return num(index - 1); + } + + return num(index); +} + val exptv(struct args *nlist) { cnum nargs = args_count(nlist); |