summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Llorens <daniel.llorens@bluewin.ch>2015-12-09 12:57:19 +0100
committerDaniel Llorens <daniel.llorens@bluewin.ch>2016-07-11 09:11:50 +0200
commitffd949e59740745c2b9a9f73dffa70878be0b344 (patch)
tree15d8f950948fbc642252b19ac0069241231c0b76
parenta8dd99d0de8d08bcfb63fa152c81b5cc110640c2 (diff)
downloadguile-ffd949e59740745c2b9a9f73dffa70878be0b344.tar.gz
New export (array-for-each-cell-in-order)
* libguile/arrays.h (array-for-each-cell-in-order): Declare. * libguile/arrays.c (array-for-each-cell-in-order): Define.
-rw-r--r--libguile/arrays.c14
-rw-r--r--libguile/arrays.h1
2 files changed, 14 insertions, 1 deletions
diff --git a/libguile/arrays.c b/libguile/arrays.c
index de86023cd..0e8c6c286 100644
--- a/libguile/arrays.c
+++ b/libguile/arrays.c
@@ -594,6 +594,7 @@ SCM_DEFINE (scm_array_for_each_cell, "array-for-each-cell", 2, 0, 1,
{
// FIXME replace stack by scm_gc_malloc_pointerless()
int const N = scm_ilength(a_);
+ int const frank = scm_to_int(frank_);
scm_t_array_handle ah[N];
SCM a[N];
scm_t_array_dim * as[N];
@@ -606,7 +607,6 @@ SCM_DEFINE (scm_array_for_each_cell, "array-for-each-cell", 2, 0, 1,
rank[n] = scm_array_handle_rank(ah+n);
}
// checks.
- int const frank = scm_to_int(frank_);
ssize_t s[frank];
char const * msg = NULL;
if (frank<0)
@@ -757,6 +757,17 @@ SCM_DEFINE (scm_array_for_each_cell, "array-for-each-cell", 2, 0, 1,
#undef FUNC_NAME
+SCM_DEFINE (scm_array_for_each_cell_in_order, "array-for-each-cell-in-order", 2, 0, 1,
+ (SCM frank_, SCM op, SCM a_),
+ "Same as array-for-each-cell, but visit the cells sequentially\n"
+ "and in row-major order.\n")
+#define FUNC_NAME s_scm_array_for_each_cell_in_order
+{
+ return scm_array_for_each_cell (frank_, op, a_);
+}
+#undef FUNC_NAME
+
+
/* args are RA . DIMS */
SCM_DEFINE (scm_transpose_array, "transpose-array", 1, 0, 1,
(SCM ra, SCM args),
@@ -1131,6 +1142,7 @@ scm_i_print_array (SCM array, SCM port, scm_print_state *pstate)
return scm_i_print_array_dimension (&h, 0, 0, port, pstate);
}
+
void
scm_init_arrays ()
{
diff --git a/libguile/arrays.h b/libguile/arrays.h
index 5a88b7238..b43e93c29 100644
--- a/libguile/arrays.h
+++ b/libguile/arrays.h
@@ -53,6 +53,7 @@ SCM_API SCM scm_array_from_s (SCM ra, SCM indices);
SCM_API SCM scm_array_from (SCM ra, SCM indices);
SCM_API SCM scm_array_amend_x (SCM ra, SCM b, SCM indices);
SCM_API SCM scm_array_for_each_cell (SCM frank, SCM op, SCM args);
+SCM_API SCM scm_array_for_each_cell_in_order (SCM frank, SCM op, SCM args);
SCM_API SCM scm_list_to_array (SCM ndim, SCM lst);
SCM_API SCM scm_list_to_typed_array (SCM type, SCM ndim, SCM lst);