unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* name an array function (follow up from guile-user)
@ 2016-12-29  6:03 daniel.llorens
  2016-12-29  6:03 ` [PATCH] Final names for new array functions daniel.llorens
  0 siblings, 1 reply; 3+ messages in thread
From: daniel.llorens @ 2016-12-29  6:03 UTC (permalink / raw)
  To: guile-devel

See https://lists.gnu.org/archive/html/guile-user/2016-12/msg00014.html. This is just renaming, but the doc could use a review.

Thanks.




^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] Final names for new array functions
  2016-12-29  6:03 name an array function (follow up from guile-user) daniel.llorens
@ 2016-12-29  6:03 ` daniel.llorens
  2017-01-08 22:09   ` Andy Wingo
  0 siblings, 1 reply; 3+ messages in thread
From: daniel.llorens @ 2016-12-29  6:03 UTC (permalink / raw)
  To: guile-devel; +Cc: Daniel Llorens

From: Daniel Llorens <daniel.llorens@bluewin.ch>

Globally rename (array-from* -> array-slice), (array-from ->
array-cell-ref), (array-amend! -> array-cell-set!), (array-for-each-cell
-> array-slice-for-each).
---
 doc/ref/api-data.texi           | 112 +++++++++++++++++++++++-----------------
 libguile/array-map.c            |  18 +++----
 libguile/array-map.h            |   4 +-
 libguile/arrays.c               |  50 +++++++++---------
 libguile/arrays.h               |   6 +--
 test-suite/tests/array-map.test |  10 ++--
 test-suite/tests/arrays.test    |  48 ++++++++---------
 7 files changed, 132 insertions(+), 116 deletions(-)

diff --git a/doc/ref/api-data.texi b/doc/ref/api-data.texi
index 58e9f43..1fbb2f2 100644
--- a/doc/ref/api-data.texi
+++ b/doc/ref/api-data.texi
@@ -7768,14 +7768,22 @@ the functionality of `enclosed arrays', a feature of old Guile that was
 removed before @w{version 2.0}. However, these functions do not require
 a special type and operate on any array.
 
-When we operate on an array in this way, we speak of the first @math{k}
-dimensions of the array as the @math{k}-`frame' of the array, while the
-last @math{n-k} dimensions are the dimensions of the
-@math{n-k}-`cell'. For example, a 2D-array (a matrix) can be seen as a
-1D array of rows. In this case, the rows are the 1-cells of the array.
-
-@deffn {Scheme Procedure} array-from array idx @dots{}
-@deffnx {C Function} scm_array_from (array, idxlist)
+We speak of the first @math{k} dimensions of the array as the
+@math{k}-`frame' of the array, while the last @math{n-k} dimensions are
+the dimensions of the @math{n-k}-`cell'. For example, a 2D-array (a
+matrix) can be seen as a 1D array of rows. In this case, the rows are
+the 1-cells of the array. This terminology originates in the J
+language.
+
+The more vague concept of a `slice' refers to a subset of the array
+where some indices are fixed and others are left free. A cell is the
+same as a `prefix slice' (it's the first indices into the original array
+that are fixed), except that a 0-cell is not a shared array of the
+original array, but a 0-slice (where all the indices into the original
+array are fixed) is.
+
+@deffn {Scheme Procedure} array-cell-ref array idx @dots{}
+@deffnx {C Function} scm_array_cell_ref (array, idxlist)
 If the length of @var{idxlist} equals the rank @math{n} of
 @var{array}, return the element at @code{(idx @dots{})}, just like
 @code{(array-ref array idx @dots{})}. If, however, the length @math{k}
@@ -7785,13 +7793,13 @@ of @var{idxlist} is shorter than @math{n}, then return the shared
 For example:
 
 @lisp
-(array-from #2((a b) (c d)) 0) @result{} #(a b)
-(array-from #2((a b) (c d)) 1) @result{} #(c d)
-(array-from #2((a b) (c d)) 1 1) @result{} d
-(array-from #2((a b) (c d))) @result{} #2((a b) (c d))
+(array-cell-ref #2((a b) (c d)) 0) @result{} #(a b)
+(array-cell-ref #2((a b) (c d)) 1) @result{} #(c d)
+(array-cell-ref #2((a b) (c d)) 1 1) @result{} d
+(array-cell-ref #2((a b) (c d))) @result{} #2((a b) (c d))
 @end lisp
 
-@code{(apply array-from array indices)} is equivalent to
+@code{(apply array-cell-ref array indices)} is equivalent to
 
 @lisp
 (let ((len (length indices)))
@@ -7802,28 +7810,27 @@ For example:
            (drop (array-dimensions a) len))))
 @end lisp
 
-The name `from' comes from the J language.
 @end deffn
 
-@deffn {Scheme Procedure} array-from* array idx @dots{}
-@deffnx {C Function} scm_array_from_s (array, idxlist)
-Like @code{(array-from array idx @dots{})}, but return a 0-rank shared
-array if the length of @var{idxlist} matches the rank of
-@var{array}. This can be useful when using @var{ARRAY} as a place to
-write into.
+@deffn {Scheme Procedure} array-slice array idx @dots{}
+@deffnx {C Function} scm_array_slice (array, idxlist)
+Like @code{(array-cell-ref array idx @dots{})}, but return a 0-rank
+shared array into @var{ARRAY} if the length of @var{idxlist} matches the
+rank of @var{array}. This can be useful when using @var{ARRAY} as a
+place to write to.
 
 Compare:
 
 @lisp
-(array-from #2((a b) (c d)) 1 1) @result{} d
-(array-from* #2((a b) (c d)) 1) @result{} #0(d)
+(array-cell-ref #2((a b) (c d)) 1 1) @result{} d
+(array-slice #2((a b) (c d)) 1 1) @result{} #0(d)
 (define a (make-array 'a 2 2))
-(array-fill! (array-from* a 1 1) 'b)
+(array-fill! (array-slice a 1 1) 'b)
 a @result{} #2((a a) (a b)).
-(array-fill! (array-from a 1 1) 'b) @result{} error: not an array
+(array-fill! (array-cell-ref a 1 1) 'b) @result{} error: not an array
 @end lisp
 
-@code{(apply array-from* array indices)} is equivalent to
+@code{(apply array-slice array indices)} is equivalent to
 
 @lisp
 (apply make-shared-array a
@@ -7833,8 +7840,8 @@ a @result{} #2((a a) (a b)).
 @end deffn
 
 
-@deffn {Scheme Procedure} array-amend! array x idx @dots{}
-@deffnx {C Function} scm_array_amend_x (array, x, idxlist)
+@deffn {Scheme Procedure} array-cell-set! array x idx @dots{}
+@deffnx {C Function} scm_array_cell_set_x (array, x, idxlist)
 If the length of @var{idxlist} equals the rank @math{n} of
 @var{array}, set the element at @code{(idx @dots{})} of @var{array} to
 @var{x}, just like @code{(array-set! array x idx @dots{})}. If,
@@ -7849,63 +7856,67 @@ This function returns the modified @var{array}.
 For example:
 
 @lisp
-(array-amend! (make-array 'a 2 2) b 1 1) @result{} #2((a a) (a b))
-(array-amend! (make-array 'a 2 2) #(x y) 1) @result{} #2((a a) (x y))
+(array-cell-set! (make-array 'a 2 2) b 1 1)
+  @result{} #2((a a) (a b))
+(array-cell-set! (make-array 'a 2 2) #(x y) 1)
+  @result{} #2((a a) (x y))
 @end lisp
 
-Note that @code{array-amend!} will expect elements, not arrays, when the
-destination has rank 0. One can work around this using
-@code{array-from*} instead.
+Note that @code{array-cell-set!} will expect elements, not arrays, when
+the destination has rank 0. Use @code{array-slice} for the opposite
+behavior.
 
 @lisp
-(array-amend! (make-array 'a 2 2) #0(b) 1 1) @result{} #2((a a) (a #0(b)))
-(let ((a (make-array 'a 2 2))) (array-copy! #0(b) (array-from* a 1 1)) a) @result{} #2((a a) (a b))
+(array-cell-set! (make-array 'a 2 2) #0(b) 1 1)
+  @result{} #2((a a) (a #0(b)))
+(let ((a (make-array 'a 2 2)))
+  (array-copy! #0(b) (array-slice a 1 1)) a)
+  @result{} #2((a a) (a b))
 @end lisp
 
-@code{(apply array-amend! array x indices)} is equivalent to
+@code{(apply array-cell-set! array x indices)} is equivalent to
 
 @lisp
 (let ((len (length indices)))
   (if (= (array-rank array) len)
     (apply array-set! array x indices)
-    (array-copy! x (apply array-from array indices)))
+    (array-copy! x (apply array-cell-ref array indices)))
   array)
 @end lisp
 
-The name `amend' comes from the J language.
 @end deffn
 
 
-@deffn {Scheme Procedure} array-for-each-cell frame-rank op x @dots{}
-@deffnx {C Function} scm_array_for_each_cell (array, frame_rank, op, xlist)
+@deffn {Scheme Procedure} array-slice-for-each frame-rank op x @dots{}
+@deffnx {C Function} scm_array_slice_for_each (array, frame_rank, op, xlist)
 Each @var{x} must be an array of rank ≥ @var{frame-rank}, and
 the first @var{frame-rank} dimensions of each @var{x} must all be the
-same. @var{array-for-each-cell} calls @var{op} with each set of
+same. @var{array-slice-for-each} calls @var{op} with each set of
 (rank(@var{x}) - @var{frame-rank})-cells from @var{x}, in unspecified order.
 
-@var{array-for-each-cell} allows you to loop over cells of any rank
-without having to carry an index list or construct slices manually. The
-cells passed to @var{op} are shared arrays of @var{X} so it is possible
-to write to them.
+@var{array-slice-for-each} allows you to loop over cells of any rank
+without having to carry an index list or construct shared arrays
+manually. The slices passed to @var{op} are always shared arrays of
+@var{X}, even if they are of rank 0, so it is possible to write to them.
 
 This function returns an unspecified value.
 
 For example, to sort the rows of rank-2 array @code{a}:
 
 @lisp
-(array-for-each-cell 1 (lambda (x) (sort! x <)) a)
+(array-slice-for-each 1 (lambda (x) (sort! x <)) a)
 @end lisp
 
 As another example, let @code{a} be a rank-2 array where each row is a 2-vector @math{(x,y)}.
 Let's compute the arguments of these vectors and store them in rank-1 array @code{b}.
 @lisp
-(array-for-each-cell 1
+(array-slice-for-each 1
   (lambda (a b)
     (array-set! b (atan (array-ref a 1) (array-ref a 0))))
   a b)
 @end lisp
 
-@code{(apply array-for-each-cell frame-rank op x)} is functionally
+@code{(apply array-slice-for-each frame-rank op x)} is functionally
 equivalent to
 
 @lisp
@@ -7916,11 +7927,16 @@ equivalent to
     (error))
   (array-index-map!
     (apply make-shared-array (make-array #t) (const '()) frame)
-    (lambda i (apply op (map (lambda (x) (apply array-from* x i)) x)))))
+    (lambda i (apply op (map (lambda (x) (apply array-slice x i)) x)))))
 @end lisp
 
 @end deffn
 
+@deffn {Scheme Procedure} array-slice-for-each-in-order frame-rank op x @dots{}
+@deffnx {C Function} scm_array_slice_for_each_in_order (array, frame_rank, op, xlist)
+Same as @code{array-slice-for-each}, but the arguments are traversed
+sequentially and in row-major order.
+@end deffn
 
 @node Accessing Arrays from C
 @subsubsection Accessing Arrays from C
diff --git a/libguile/array-map.c b/libguile/array-map.c
index 19e85c3..c2825bc 100644
--- a/libguile/array-map.c
+++ b/libguile/array-map.c
@@ -655,7 +655,7 @@ scm_i_array_rebase (SCM a, size_t base)
 
 static inline size_t padtoptr(size_t d) { return (d + (sizeof (void *) - 1)) & ~(sizeof (void *) - 1); }
 
-SCM_DEFINE (scm_array_for_each_cell, "array-for-each-cell", 2, 0, 1,
+SCM_DEFINE (scm_array_slice_for_each, "array-slice-for-each", 2, 0, 1,
             (SCM frame_rank, SCM op, SCM args),
             "Apply @var{op} to each of the cells of rank rank(@var{arg})-@var{frame_rank}\n"
             "of the arrays @var{args}, in unspecified order. The first\n"
@@ -665,17 +665,17 @@ SCM_DEFINE (scm_array_for_each_cell, "array-for-each-cell", 2, 0, 1,
             "For example:\n"
             "@lisp\n"
             ";; Sort the rows of rank-2 array A.\n\n"
-            "(array-for-each-cell 1 (lambda (x) (sort! x <)) a)\n"
+            "(array-slice-for-each 1 (lambda (x) (sort! x <)) a)\n"
             "\n"
             ";; Compute the arguments of the (x y) vectors in the rows of rank-2\n"
             ";; array XYS and store them in rank-1 array ANGLES. Inside OP,\n"
             ";; XY is a rank-1 (2-1) array, and ANGLE is a rank-0 (1-1) array.\n\n"
-            "(array-for-each-cell 1 \n"
+            "(array-slice-for-each 1 \n"
             "  (lambda (xy angle)\n"
             "    (array-set! angle (atan (array-ref xy 1) (array-ref xy 0))))\n"
             "  xys angles)\n"
             "@end lisp")
-#define FUNC_NAME s_scm_array_for_each_cell
+#define FUNC_NAME s_scm_array_slice_for_each
 {
   int const N = scm_ilength (args);
   int const frank = scm_to_int (frame_rank);
@@ -787,7 +787,7 @@ SCM_DEFINE (scm_array_for_each_cell, "array-for-each-cell", 2, 0, 1,
     {
       for (n=0; n!=N; ++n)
         scm_array_handle_release(ah+n);
-      scm_misc_error("array-for-each-cell", msg, scm_cons_star(frame_rank, args));
+      scm_misc_error("array-slice-for-each", msg, scm_cons_star(frame_rank, args));
     }
   /* prepare moving cells. */
   for (n=0; n!=N; ++n)
@@ -884,13 +884,13 @@ 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_DEFINE (scm_array_slice_for_each_in_order, "array-slice-for-each-in-order", 2, 0, 1,
             (SCM frank, SCM op, SCM a),
-            "Same as array-for-each-cell, but visit the cells sequentially\n"
+            "Same as array-slice-for-each, but visit the cells sequentially\n"
             "and in row-major order.\n")
-#define FUNC_NAME s_scm_array_for_each_cell_in_order
+#define FUNC_NAME s_scm_array_slice_for_each_in_order
 {
-  return scm_array_for_each_cell (frank, op, a);
+  return scm_array_slice_for_each (frank, op, a);
 }
 #undef FUNC_NAME
 
diff --git a/libguile/array-map.h b/libguile/array-map.h
index acfdd5e..12351d1 100644
--- a/libguile/array-map.h
+++ b/libguile/array-map.h
@@ -37,8 +37,8 @@ SCM_API SCM scm_array_map_x (SCM ra0, SCM proc, SCM lra);
 SCM_API SCM scm_array_for_each (SCM proc, SCM ra0, SCM lra);
 SCM_API SCM scm_array_index_map_x (SCM ra, SCM proc);
 SCM_API SCM scm_array_equal_p (SCM ra0, SCM ra1);
-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_array_slice_for_each (SCM frank, SCM op, SCM args);
+SCM_API SCM scm_array_slice_for_each_in_order (SCM frank, SCM op, SCM args);
 
 SCM_INTERNAL SCM scm_i_array_rebase (SCM a, size_t base);
 SCM_INTERNAL void scm_init_array_map (void);
diff --git a/libguile/arrays.c b/libguile/arrays.c
index b17c415..8b8bc48 100644
--- a/libguile/arrays.c
+++ b/libguile/arrays.c
@@ -468,19 +468,19 @@ array_from_get_o (scm_t_array_handle *handle, size_t k, scm_t_array_dim *s, ssiz
     }
 }
 
-SCM_DEFINE (scm_array_from_s, "array-from*", 1, 0, 1,
+SCM_DEFINE (scm_array_slice, "array-slice", 1, 0, 1,
            (SCM ra, SCM indices),
             "Return the array slice @var{ra}[@var{indices} ..., ...]\n"
             "The rank of @var{ra} must equal to the number of indices or larger.\n\n"
-            "See also @code{array-ref}, @code{array-from}, @code{array-amend!}.\n\n"
-            "@code{array-from*} may return a rank-0 array. For example:\n"
+            "See also @code{array-ref}, @code{array-cell-ref}, @code{array-cell-set!}.\n\n"
+            "@code{array-slice} may return a rank-0 array. For example:\n"
             "@lisp\n"
-            "(array-from* #2((1 2 3) (4 5 6)) 1 1) @result{} #0(5)\n"
-            "(array-from* #2((1 2 3) (4 5 6)) 1) @result{} #(4 5 6)\n"
-            "(array-from* #2((1 2 3) (4 5 6))) @result{} #2((1 2 3) (4 5 6))\n"
-            "(array-from* #0(5) @result{} #0(5).\n"
+            "(array-slice #2((1 2 3) (4 5 6)) 1 1) @result{} #0(5)\n"
+            "(array-slice #2((1 2 3) (4 5 6)) 1) @result{} #(4 5 6)\n"
+            "(array-slice #2((1 2 3) (4 5 6))) @result{} #2((1 2 3) (4 5 6))\n"
+            "(array-slice #0(5) @result{} #0(5).\n"
             "@end lisp")
-#define FUNC_NAME s_scm_array_from_s
+#define FUNC_NAME s_scm_array_slice
 {
   SCM o, i = indices;
   size_t ndim, k;
@@ -506,20 +506,20 @@ SCM_DEFINE (scm_array_from_s, "array-from*", 1, 0, 1,
 #undef FUNC_NAME
 
 
-SCM_DEFINE (scm_array_from, "array-from", 1, 0, 1,
+SCM_DEFINE (scm_array_cell_ref, "array-cell-ref", 1, 0, 1,
            (SCM ra, SCM indices),
             "Return the element at the @code{(@var{indices} ...)} position\n"
             "in array @var{ra}, or the array slice @var{ra}[@var{indices} ..., ...]\n"
             "if the rank of @var{ra} is larger than the number of indices.\n\n"
-            "See also @code{array-ref}, @code{array-from*}, @code{array-amend!}.\n\n"
-            "@code{array-from} never returns a rank 0 array. For example:\n"
+            "See also @code{array-ref}, @code{array-slice}, @code{array-cell-set!}.\n\n"
+            "@code{array-cell-ref} never returns a rank 0 array. For example:\n"
             "@lisp\n"
-            "(array-from #2((1 2 3) (4 5 6)) 1 1) @result{} 5\n"
-            "(array-from #2((1 2 3) (4 5 6)) 1) @result{} #(4 5 6)\n"
-            "(array-from #2((1 2 3) (4 5 6))) @result{} #2((1 2 3) (4 5 6))\n"
-            "(array-from #0(5) @result{} 5.\n"
+            "(array-cell-ref #2((1 2 3) (4 5 6)) 1 1) @result{} 5\n"
+            "(array-cell-ref #2((1 2 3) (4 5 6)) 1) @result{} #(4 5 6)\n"
+            "(array-cell-ref #2((1 2 3) (4 5 6))) @result{} #2((1 2 3) (4 5 6))\n"
+            "(array-cell-ref #0(5) @result{} 5.\n"
             "@end lisp")
-#define FUNC_NAME s_scm_array_from
+#define FUNC_NAME s_scm_array_cell_ref
 {
   SCM o, i = indices;
   size_t ndim, k;
@@ -548,25 +548,25 @@ SCM_DEFINE (scm_array_from, "array-from", 1, 0, 1,
 #undef FUNC_NAME
 
 
-SCM_DEFINE (scm_array_amend_x, "array-amend!", 2, 0, 1,
+SCM_DEFINE (scm_array_cell_set_x, "array-cell-set!", 2, 0, 1,
             (SCM ra, SCM b, SCM indices),
             "Set the array slice @var{ra}[@var{indices} ..., ...] to @var{b}\n."
-            "Equivalent to @code{(array-copy! @var{b} (apply array-from @var{ra} @var{indices}))}\n"
+            "Equivalent to @code{(array-copy! @var{b} (apply array-cell-ref @var{ra} @var{indices}))}\n"
             "if the number of indices is smaller than the rank of @var{ra}; otherwise\n"
             "equivalent to @code{(apply array-set! @var{ra} @var{b} @var{indices})}.\n"
             "This function returns the modified array @var{ra}.\n\n"
-            "See also @code{array-ref}, @code{array-from}, @code{array-from*}.\n\n"
+            "See also @code{array-ref}, @code{array-cell-ref}, @code{array-slice}.\n\n"
             "For example:\n"
             "@lisp\n"
             "(define A (list->array 2 '((1 2 3) (4 5 6))))\n"
-            "(array-amend! A #0(99) 1 1) @result{} #2((1 2 3) (4 #0(99) 6))\n"
-            "(array-amend! A 99 1 1) @result{} #2((1 2 3) (4 99 6))\n"
-            "(array-amend! A #(a b c) 0) @result{} #2((a b c) (4 99 6))\n"
-            "(array-amend! A #2((x y z) (9 8 7))) @result{} #2((x y z) (9 8 7))\n\n"
+            "(array-cell-set! A #0(99) 1 1) @result{} #2((1 2 3) (4 #0(99) 6))\n"
+            "(array-cell-set! A 99 1 1) @result{} #2((1 2 3) (4 99 6))\n"
+            "(array-cell-set! A #(a b c) 0) @result{} #2((a b c) (4 99 6))\n"
+            "(array-cell-set! A #2((x y z) (9 8 7))) @result{} #2((x y z) (9 8 7))\n\n"
             "(define B (make-array 0))\n"
-            "(array-amend! B 15) @result{} #0(15)\n"
+            "(array-cell-set! B 15) @result{} #0(15)\n"
             "@end lisp")
-#define FUNC_NAME s_scm_array_amend_x
+#define FUNC_NAME s_scm_array_cell_set_x
 {
   SCM o, i = indices;
   size_t ndim, k;
diff --git a/libguile/arrays.h b/libguile/arrays.h
index 37eea69..b56abef 100644
--- a/libguile/arrays.h
+++ b/libguile/arrays.h
@@ -49,9 +49,9 @@ SCM_API SCM scm_shared_array_increments (SCM ra);
 SCM_API SCM scm_make_shared_array (SCM oldra, SCM mapfunc, SCM dims);
 SCM_API SCM scm_transpose_array (SCM ra, SCM args);
 SCM_API SCM scm_array_contents (SCM ra, SCM strict);
-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_slice (SCM ra, SCM indices);
+SCM_API SCM scm_array_cell_ref (SCM ra, SCM indices);
+SCM_API SCM scm_array_cell_set_x (SCM ra, SCM b, SCM indices);
 
 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);
diff --git a/test-suite/tests/array-map.test b/test-suite/tests/array-map.test
index 3095b78..3471841 100644
--- a/test-suite/tests/array-map.test
+++ b/test-suite/tests/array-map.test
@@ -509,29 +509,29 @@
         (array-for-each (lambda (b c) (set! a (cons* b c a))) b c)))))
 
 ;;;
-;;; array-for-each-cell
+;;; array-slice-for-each
 ;;;
 
-(with-test-prefix "array-for-each-cell"
+(with-test-prefix "array-slice-for-each"
 
   (pass-if-equal "1 argument frame rank 1"
       #2((1 3 9) (2 7 8))
       (let* ((a (list->array 2 '((9 1 3) (7 8 2)))))
-        (array-for-each-cell 1 (lambda (a) (sort! a <)) a)
+        (array-slice-for-each 1 (lambda (a) (sort! a <)) a)
         a))
 
   (pass-if-equal "2 arguments frame rank 1"
       #f64(8 -1)
       (let* ((x (list->typed-array 'f64 2 '((9 1) (7 8))))
              (y (f64vector 99 99)))
-        (array-for-each-cell 1 (lambda (y x) (array-set! y (- (array-ref x 0) (array-ref x 1)))) y x)
+        (array-slice-for-each 1 (lambda (y x) (array-set! y (- (array-ref x 0) (array-ref x 1)))) y x)
         y))
 
   (pass-if-equal "regression: zero-sized frame loop without unrolling"
       99
     (let* ((x 99)
            (o (make-array 0. 0 3 2)))
-      (array-for-each-cell 2
+      (array-slice-for-each 2
         (lambda (o a0 a1)
           (set! x 0))
         o
diff --git a/test-suite/tests/arrays.test b/test-suite/tests/arrays.test
index 4c943dd..1df77b1 100644
--- a/test-suite/tests/arrays.test
+++ b/test-suite/tests/arrays.test
@@ -298,110 +298,110 @@
 
 
 ;;;
-;;; array-from*
+;;; array-slice
 ;;;
 
-(with-test-prefix/c&e "array-from*"
+(with-test-prefix/c&e "array-slice"
 
   (pass-if "vector I"
     (let ((v (vector 1 2 3)))
-      (array-fill! (array-from* v 1) 'a)
+      (array-fill! (array-slice v 1) 'a)
       (array-equal? v #(1 a 3))))
 
   (pass-if "vector II"
     (let ((v (vector 1 2 3)))
-      (array-copy! #(a b c) (array-from* v))
+      (array-copy! #(a b c) (array-slice v))
       (array-equal? v #(a b c))))
 
   (pass-if "array I"
     (let ((a (list->array 2 '((1 2 3) (4 5 6)))))
-      (array-fill! (array-from* a 1 1) 'a)
+      (array-fill! (array-slice a 1 1) 'a)
       (array-equal? a #2((1 2 3) (4 a 6)))))
 
   (pass-if "array II"
     (let ((a (list->array 2 '((1 2 3) (4 5 6)))))
-      (array-copy! #(a b c) (array-from* a 1))
+      (array-copy! #(a b c) (array-slice a 1))
       (array-equal? a #2((1 2 3) (a b c)))))
 
   (pass-if "array III"
     (let ((a (list->array 2 '((1 2 3) (4 5 6)))))
-      (array-copy! #2((a b c) (x y z)) (array-from* a))
+      (array-copy! #2((a b c) (x y z)) (array-slice a))
       (array-equal? a #2((a b c) (x y z)))))
 
   (pass-if "rank 0 array"
     (let ((a (make-array 77)))
-      (array-fill! (array-from* a) 'a)
+      (array-fill! (array-slice a) 'a)
       (array-equal? a #0(a)))))
 
 
 ;;;
-;;; array-from
+;;; array-cell-ref
 ;;;
 
-(with-test-prefix/c&e "array-from"
+(with-test-prefix/c&e "array-cell-ref"
 
   (pass-if "vector I"
     (let ((v (vector 1 2 3)))
-      (equal? 2 (array-from v 1))))
+      (equal? 2 (array-cell-ref v 1))))
 
   (pass-if "vector II"
     (let ((v (vector 1 2 3)))
-      (array-copy! #(a b c) (array-from v))
+      (array-copy! #(a b c) (array-cell-ref v))
       (array-equal? v #(a b c))))
 
   (pass-if "array I"
     (let ((a (list->array 2 '((1 2 3) (4 5 6)))))
-      (equal? 5 (array-from a 1 1))))
+      (equal? 5 (array-cell-ref a 1 1))))
 
   (pass-if "array II"
     (let ((a (list->array 2 '((1 2 3) (4 5 6)))))
-      (array-copy! #(a b c) (array-from a 1))
+      (array-copy! #(a b c) (array-cell-ref a 1))
       (array-equal? a #2((1 2 3) (a b c)))))
 
   (pass-if "array III"
     (let ((a (list->array 2 '((1 2 3) (4 5 6)))))
-      (array-copy! #2((a b c) (x y z)) (array-from a))
+      (array-copy! #2((a b c) (x y z)) (array-cell-ref a))
       (array-equal? a #2((a b c) (x y z)))))
 
   (pass-if "rank 0 array"
     (let ((a (make-array 77)))
-      (equal? (array-from a) 77))))
+      (equal? (array-cell-ref a) 77))))
 
 
 ;;;
-;;; array-amend!
+;;; array-cell-set!
 ;;;
 
-(with-test-prefix/c&e "array-amend!"
+(with-test-prefix/c&e "array-cell-set!"
 
   (pass-if "vector I"
     (let ((v (vector 1 2 3)))
-      (and (eq? v (array-amend! v 'x 1))
+      (and (eq? v (array-cell-set! v 'x 1))
            (array-equal? v #(1 x 3)))))
 
   (pass-if "vector II"
     (let ((v (vector 1 2 3)))
-      (and (eq? v (array-amend! (array-from v) #(a b c)))
+      (and (eq? v (array-cell-set! (array-cell-ref v) #(a b c)))
            (array-equal? v #(a b c)))))
 
   (pass-if "array I"
     (let ((a (list->array 2 '((1 2 3) (4 5 6)))))
-      (and (eq? a (array-amend! a 'x 1 1))
+      (and (eq? a (array-cell-set! a 'x 1 1))
            (array-equal? a #2((1 2 3) (4 x 6))))))
 
   (pass-if "array II"
     (let ((a (list->array 2 '((1 2 3) (4 5 6)))))
-      (and (eq? a (array-amend! a #(a b c) 1))
+      (and (eq? a (array-cell-set! a #(a b c) 1))
            (array-equal? a #2((1 2 3) (a b c))))))
 
   (pass-if "array III"
     (let ((a (list->array 2 '((1 2 3) (4 5 6)))))
-      (and (eq? a (array-amend! a #2((a b c) (x y z))))
+      (and (eq? a (array-cell-set! a #2((a b c) (x y z))))
            (array-equal? a #2((a b c) (x y z))))))
 
   (pass-if "rank 0 array"
     (let ((a (make-array 77)))
-      (and (eq? a (array-amend! a 99))
+      (and (eq? a (array-cell-set! a 99))
            (array-equal? a #0(99))))))
 
 
-- 
2.10.1




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Final names for new array functions
  2016-12-29  6:03 ` [PATCH] Final names for new array functions daniel.llorens
@ 2017-01-08 22:09   ` Andy Wingo
  0 siblings, 0 replies; 3+ messages in thread
From: Andy Wingo @ 2017-01-08 22:09 UTC (permalink / raw)
  To: daniel.llorens; +Cc: guile-devel

On Thu 29 Dec 2016 07:03, daniel.llorens@bluewin.ch writes:

> From: Daniel Llorens <daniel.llorens@bluewin.ch>
>
> Globally rename (array-from* -> array-slice), (array-from ->
> array-cell-ref), (array-amend! -> array-cell-set!), (array-for-each-cell
> -> array-slice-for-each).

LGTM, please apply.  Thanks :)

Andy



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-01-08 22:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-29  6:03 name an array function (follow up from guile-user) daniel.llorens
2016-12-29  6:03 ` [PATCH] Final names for new array functions daniel.llorens
2017-01-08 22:09   ` Andy Wingo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).