(fifth, sixth, seventh, eighth, ninth, tenth): Rewrite in C.
authorKevin Ryde <user42@zip.com.au>
Tue, 3 May 2005 23:24:31 +0000 (23:24 +0000)
committerKevin Ryde <user42@zip.com.au>
Tue, 3 May 2005 23:24:31 +0000 (23:24 +0000)
srfi/srfi-1.c
srfi/srfi-1.h
srfi/srfi-1.scm

index 6c1da2d..a746732 100644 (file)
@@ -674,6 +674,26 @@ SCM_DEFINE (scm_srfi1_drop_while, "drop-while", 2, 0, 0,
 #undef FUNC_NAME
 
 
+SCM_DEFINE (scm_srfi1_eighth, "eighth", 1, 0, 0,
+            (SCM lst),
+           "Return the eighth element of @var{lst}.")
+#define FUNC_NAME s_scm_srfi1_eighth
+{
+  return scm_list_ref (lst, SCM_I_MAKINUM (7));
+}
+#undef FUNC_NAME
+
+
+SCM_DEFINE (scm_srfi1_fifth, "fifth", 1, 0, 0,
+            (SCM lst),
+           "Return the fifth element of @var{lst}.")
+#define FUNC_NAME s_scm_srfi1_fifth
+{
+  return scm_list_ref (lst, SCM_I_MAKINUM (4));
+}
+#undef FUNC_NAME
+
+
 SCM_DEFINE (scm_srfi1_filter_map, "filter-map", 2, 0, 1,
             (SCM proc, SCM list1, SCM rest),
            "Apply @var{proc} to to the elements of @var{list1} @dots{} and\n"
@@ -1188,6 +1208,17 @@ SCM_DEFINE (scm_srfi1_assoc, "assoc", 2, 1, 0,
 }
 #undef FUNC_NAME
 
+
+SCM_DEFINE (scm_srfi1_ninth, "ninth", 1, 0, 0,
+            (SCM lst),
+           "Return the ninth element of @var{lst}.")
+#define FUNC_NAME s_scm_srfi1_ninth
+{
+  return scm_list_ref (lst, SCM_I_MAKINUM (8));
+}
+#undef FUNC_NAME
+
+
 SCM_DEFINE (scm_srfi1_partition, "partition", 2, 0, 0,
            (SCM pred, SCM list),
            "Partition the elements of @var{list} with predicate @var{pred}.\n"
@@ -1474,6 +1505,26 @@ SCM_DEFINE (scm_srfi1_remove_x, "remove!", 2, 0, 0,
 #undef FUNC_NAME
 
 
+SCM_DEFINE (scm_srfi1_seventh, "seventh", 1, 0, 0,
+            (SCM lst),
+           "Return the seventh element of @var{lst}.")
+#define FUNC_NAME s_scm_srfi1_seventh
+{
+  return scm_list_ref (lst, SCM_I_MAKINUM (6));
+}
+#undef FUNC_NAME
+
+
+SCM_DEFINE (scm_srfi1_sixth, "sixth", 1, 0, 0,
+            (SCM lst),
+           "Return the sixth element of @var{lst}.")
+#define FUNC_NAME s_scm_srfi1_sixth
+{
+  return scm_list_ref (lst, SCM_I_MAKINUM (5));
+}
+#undef FUNC_NAME
+
+
 SCM_DEFINE (scm_srfi1_span, "span", 2, 0, 0,
             (SCM pred, SCM lst),
            "Return two values, the longest initial prefix of @var{lst}\n"
@@ -1699,6 +1750,16 @@ SCM_DEFINE (scm_srfi1_take_while_x, "take-while!", 2, 0, 0,
 #undef FUNC_NAME
 
 
+SCM_DEFINE (scm_srfi1_tenth, "tenth", 1, 0, 0,
+            (SCM lst),
+           "Return the tenth element of @var{lst}.")
+#define FUNC_NAME s_scm_srfi1_tenth
+{
+  return scm_list_ref (lst, SCM_I_MAKINUM (9));
+}
+#undef FUNC_NAME
+
+
 void
 scm_init_srfi_1 (void)
 {
index 83f3da6..3f8f81e 100644 (file)
@@ -45,6 +45,8 @@ SCM_SRFI1_API SCM scm_srfi1_delete_duplicates_x (SCM lst, SCM pred);
 SCM_SRFI1_API SCM scm_srfi1_drop_right (SCM lst, SCM n);
 SCM_SRFI1_API SCM scm_srfi1_drop_right_x (SCM lst, SCM n);
 SCM_SRFI1_API SCM scm_srfi1_drop_while (SCM pred, SCM lst);
+SCM_SRFI1_API SCM scm_srfi1_eighth (SCM lst);
+SCM_SRFI1_API SCM scm_srfi1_fifth (SCM lst);
 SCM_SRFI1_API SCM scm_srfi1_filter_map (SCM proc, SCM list1, SCM rest);
 SCM_SRFI1_API SCM scm_srfi1_find (SCM pred, SCM lst);
 SCM_SRFI1_API SCM scm_srfi1_find_tail (SCM pred, SCM lst);
@@ -54,6 +56,7 @@ SCM_SRFI1_API SCM scm_srfi1_list_copy (SCM lst);
 SCM_SRFI1_API SCM scm_srfi1_map (SCM proc, SCM arg1, SCM args);
 SCM_SRFI1_API SCM scm_srfi1_for_each (SCM proc, SCM arg1, SCM args);
 SCM_SRFI1_API SCM scm_srfi1_member (SCM obj, SCM ls, SCM pred);
+SCM_SRFI1_API SCM scm_srfi1_ninth (SCM lst);
 SCM_SRFI1_API SCM scm_srfi1_assoc (SCM key, SCM alist, SCM pred);
 SCM_SRFI1_API SCM scm_srfi1_partition (SCM pred, SCM list);
 SCM_SRFI1_API SCM scm_srfi1_partition_x (SCM pred, SCM list);
@@ -61,6 +64,8 @@ SCM_SRFI1_API SCM scm_srfi1_reduce (SCM proc, SCM def, SCM lst);
 SCM_SRFI1_API SCM scm_srfi1_reduce_right (SCM proc, SCM def, SCM lst);
 SCM_SRFI1_API SCM scm_srfi1_remove (SCM pred, SCM list);
 SCM_SRFI1_API SCM scm_srfi1_remove_x (SCM pred, SCM list);
+SCM_SRFI1_API SCM scm_srfi1_seventh (SCM lst);
+SCM_SRFI1_API SCM scm_srfi1_sixth (SCM lst);
 SCM_SRFI1_API SCM scm_srfi1_span (SCM pred, SCM lst);
 SCM_SRFI1_API SCM scm_srfi1_span_x (SCM pred, SCM lst);
 SCM_SRFI1_API SCM scm_srfi1_split_at (SCM lst, SCM n);
@@ -69,6 +74,7 @@ SCM_SRFI1_API SCM scm_srfi1_take_x (SCM lst, SCM n);
 SCM_SRFI1_API SCM scm_srfi1_take_right (SCM lst, SCM n);
 SCM_SRFI1_API SCM scm_srfi1_take_while (SCM pred, SCM lst);
 SCM_SRFI1_API SCM scm_srfi1_take_while_x (SCM pred, SCM lst);
+SCM_SRFI1_API SCM scm_srfi1_tenth (SCM lst);
 
 SCM_SRFI1_API void scm_init_srfi_1 (void);
 
index 7e1fcf4..36da13b 100644 (file)
 (define second cadr)
 (define third caddr)
 (define fourth cadddr)
-(define (fifth x) (car (cddddr x)))
-(define (sixth x) (cadr (cddddr x)))
-(define (seventh x) (caddr (cddddr x)))
-(define (eighth x) (cadddr (cddddr x)))
-(define (ninth x) (car (cddddr (cddddr x))))
-(define (tenth x) (cadr (cddddr (cddddr x))))
 
 (define (car+cdr x) (values (car x) (cdr x)))