diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-07-22 07:37:22 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-07-22 07:37:22 -0700 |
commit | 420a230dbae897ee32c03297f7e4bb18f683a8b1 (patch) | |
tree | ca542bbde5776b9a5f8ed5ecbd1769dc19956038 /lib.c | |
parent | fb8a30d4540d04b02f98e7895cdb02d5c7f6c2e6 (diff) | |
download | txr-420a230dbae897ee32c03297f7e4bb18f683a8b1.tar.gz txr-420a230dbae897ee32c03297f7e4bb18f683a8b1.tar.bz2 txr-420a230dbae897ee32c03297f7e4bb18f683a8b1.zip |
Implementing second through tenth as places.
* eval.c (eval_init): Register second through tenth as intrinsic.
* gencadr.txr: New cadr.c changes encoded.
* lib.c (second, third, fourth, fifth, sixth): Functions
reimplemented using ref, so they are much more efficient
for vectors and strings.
(seventh, eighth, ninth, tenth): New functions.
* lib.h (seventh, eighth, ninth, tenth): Declared.
* share/txr/stdlib/place.tl: place macros defined for
second through tenth.
* txr.1: Documented.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 40 |
1 files changed, 30 insertions, 10 deletions
@@ -367,29 +367,49 @@ val rest(val cons) return cdr(cons); } -val second(val cons) +val second(val obj) { - return car(cdr(cons)); + return ref(obj, one); } -val third(val cons) +val third(val obj) { - return car(cdr(cdr(cons))); + return ref(obj, two); } -val fourth(val cons) +val fourth(val obj) { - return car(cdr(cdr(cdr(cons)))); + return ref(obj, three); } -val fifth(val cons) +val fifth(val obj) { - return car(cdr(cdr(cdr(cdr(cons))))); + return ref(obj, four); } -val sixth(val cons) +val sixth(val obj) { - return car(cdr(cdr(cdr(cdr(cdr(cons)))))); + return ref(obj, num_fast(5)); +} + +val seventh(val obj) +{ + return ref(obj, num_fast(6)); +} + +val eighth(val obj) +{ + return ref(obj, num_fast(7)); +} + +val ninth(val obj) +{ + return ref(obj, num_fast(8)); +} + +val tenth(val obj) +{ + return ref(obj, num_fast(9)); } val conses(val list) |