summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-07-22 07:37:22 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-07-22 07:37:22 -0700
commit420a230dbae897ee32c03297f7e4bb18f683a8b1 (patch)
treeca542bbde5776b9a5f8ed5ecbd1769dc19956038 /lib.c
parentfb8a30d4540d04b02f98e7895cdb02d5c7f6c2e6 (diff)
downloadtxr-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.c40
1 files changed, 30 insertions, 10 deletions
diff --git a/lib.c b/lib.c
index 9bcce5e4..4d0c901b 100644
--- a/lib.c
+++ b/lib.c
@@ -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)