commit 3f2fa9e4054490a6f220dff4a599a25c509a1512
parent f47cd77a98a21d4efcb7223c09a26a92731cab3a
Author: Andres Navarro <canavarro82@gmail.com>
Date: Fri, 25 Nov 2011 13:00:59 -0300
Added list-copy to the ground environment.
Diffstat:
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/TODO b/TODO
@@ -12,6 +12,9 @@
clutter (e.g. when creating continuations)
** Study differrent c interfaces (maybe a stack like in lua would be
better than dealing with gc push/pop
+** eliminate char * arguments where not needed (like list check/copy
+ functions in kghelpers
+** check if all inline functions need to be inline
* fix:
** current-jiffy (r7rs)
** jiffies-per-second (r7rs)
@@ -28,7 +31,6 @@
** $do (r7rs)
* applicatives:
** reverse (r7rs)
-** list-copy (r7rs)
** list-set! (r7rs)
** vector-map (r7rs)
** bytevector-map (r7rs)
diff --git a/src/kgpairs_lists.c b/src/kgpairs_lists.c
@@ -94,6 +94,22 @@ void make_list(klisp_State *K)
kapply_cc(K, tail);
}
+/* 5.2.? list-copy */
+void list_copy(klisp_State *K)
+{
+ TValue *xparams = K->next_xparams;
+ TValue ptree = K->next_value;
+ TValue denv = K->next_env;
+ klisp_assert(ttisenvironment(K->next_env));
+
+ UNUSED(xparams);
+ UNUSED(denv);
+
+ bind_1p(K, ptree, ls);
+ TValue copy = check_copy_list(K, "list-copy", ls, true);
+ kapply_cc(K, copy);
+}
+
/* 5.2.2 list* */
void listS(klisp_State *K)
{
@@ -1200,6 +1216,8 @@ void kinit_pairs_lists_ground_env(klisp_State *K)
C_AD_R_PARAM(4, 0x1111));
/* 5.?.? make-list */
add_applicative(K, ground_env, "make-list", make_list, 0);
+ /* 5.?.? list-copy */
+ add_applicative(K, ground_env, "list-copy", list_copy, 0);
/* 5.7.1 get-list-metrics */
add_applicative(K, ground_env, "get-list-metrics", get_list_metrics, 0);
/* 5.7.2 list-tail */