summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Llorens <daniel.llorens@bluewin.ch>2015-02-11 19:32:02 +0100
committerDaniel Llorens <daniel.llorens@bluewin.ch>2016-07-11 09:11:50 +0200
commit3aafc2c857541fc4d015b5d6ba2ac075f50240d0 (patch)
treec6ad4e5e3bda61dff42281ecfecb72fa0f39fcb4
parentecb38d4268fdbb764473f2c723c7b0a9aef3eb25 (diff)
downloadguile-3aafc2c857541fc4d015b5d6ba2ac075f50240d0.tar.gz
Rename array-set-from!, scm_array_set_from_x to array-amend!, scm_array_amend_x
-rw-r--r--doc/ref/api-compound.texi12
-rw-r--r--libguile/arrays.c18
-rw-r--r--libguile/arrays.h2
-rw-r--r--test-suite/tests/arrays.test16
4 files changed, 25 insertions, 23 deletions
diff --git a/doc/ref/api-compound.texi b/doc/ref/api-compound.texi
index 23f2de0cd..7f70374dc 100644
--- a/doc/ref/api-compound.texi
+++ b/doc/ref/api-compound.texi
@@ -1778,8 +1778,8 @@ a @result{} #2((a a) (a b)).
@end deffn
-@deffn {Scheme Procedure} array-set-from! array x idx @dots{}
-@deffnx {C Function} scm_array_set_from_x (array, x, idxlist)
+@deffn {Scheme Procedure} array-amend! array x idx @dots{}
+@deffnx {C Function} scm_array_amend_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,
@@ -1795,12 +1795,12 @@ For example:
@example
@lisp
-(array-set-from! (make-array 'a 2 2) b 1 1) @result{} #2((a a) (a b))
-(array-set-from! (make-array 'a 2 2) #(x y) 1) @result{} #2((a a) (x y))
+(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))
@end lisp
@end example
-@code{(apply array-set-from! array x indices)} is equivalent to
+@code{(apply array-amend! array x indices)} is equivalent to
@lisp
(let ((len (length indices)))
@@ -1809,6 +1809,8 @@ For example:
(array-copy! x (apply array-from array indices)))
array)
@end lisp
+
+The name `amend' comes from the J language.
@end deffn
diff --git a/libguile/arrays.c b/libguile/arrays.c
index 31474ed18..6d1927c13 100644
--- a/libguile/arrays.c
+++ b/libguile/arrays.c
@@ -431,7 +431,7 @@ SCM_DEFINE (scm_array_from_s, "array-from*", 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-set-from!}.\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"
"@lisp\n"
"(array-from* #2((1 2 3) (4 5 6)) 1 1) @result{} #0(5)\n"
@@ -463,7 +463,7 @@ SCM_DEFINE (scm_array_from, "array-from", 1, 0, 1,
"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-set-from!}.\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"
"@lisp\n"
"(array-from #2((1 2 3) (4 5 6)) 1 1) @result{} 5\n"
@@ -495,7 +495,7 @@ SCM_DEFINE (scm_array_from, "array-from", 1, 0, 1,
#undef FUNC_NAME
-SCM_DEFINE (scm_array_set_from_x, "array-set-from!", 2, 0, 1,
+SCM_DEFINE (scm_array_amend_x, "array-amend!", 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"
@@ -506,14 +506,14 @@ SCM_DEFINE (scm_array_set_from_x, "array-set-from!", 2, 0, 1,
"For example:\n"
"@lisp\n"
"(define A (list->array 2 '((1 2 3) (4 5 6))))\n"
- "(array-set-from! A #0(99) 1 1) @result{} #2((1 2 3) (4 #0(99) 6))\n"
- "(array-set-from! A 99 1 1) @result{} #2((1 2 3) (4 99 6))\n"
- "(array-set-from! A #(a b c) 0) @result{} #2((a b c) (4 99 6))\n"
- "(array-set-from! A #2((x y z) (9 8 7))) @result{} #2((x y z) (9 8 7))\n\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"
"(define B (make-array 0))\n"
- "(array-set-from! B 15) @result{} #0(15)\n"
+ "(array-amend! B 15) @result{} #0(15)\n"
"@end lisp")
-#define FUNC_NAME s_scm_array_set_from_x
+#define FUNC_NAME s_scm_array_amend_x
{
ARRAY_FROM_POS(scm_list_3 (ra, b, indices))
SCM o;
diff --git a/libguile/arrays.h b/libguile/arrays.h
index 6399333f9..bd216aede 100644
--- a/libguile/arrays.h
+++ b/libguile/arrays.h
@@ -51,7 +51,7 @@ 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_set_from_x (SCM ra, SCM b, SCM indices);
+SCM_API SCM scm_array_amend_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/arrays.test b/test-suite/tests/arrays.test
index dfcd6f8f1..c6027c2ec 100644
--- a/test-suite/tests/arrays.test
+++ b/test-suite/tests/arrays.test
@@ -363,39 +363,39 @@
;;;
-;;; array-set-from!
+;;; array-amend!
;;;
-(with-test-prefix/c&e "array-set-from!"
+(with-test-prefix/c&e "array-amend!"
(pass-if "vector I"
(let ((v (vector 1 2 3)))
- (and (eq? v (array-set-from! v 'x 1))
+ (and (eq? v (array-amend! v 'x 1))
(array-equal? v #(1 x 3)))))
(pass-if "vector II"
(let ((v (vector 1 2 3)))
- (and (eq? v (array-set-from! (array-from v) #(a b c)))
+ (and (eq? v (array-amend! (array-from 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-set-from! a 'x 1 1))
+ (and (eq? a (array-amend! 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-set-from! a #(a b c) 1))
+ (and (eq? a (array-amend! 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-set-from! a #2((a b c) (x y z))))
+ (and (eq? a (array-amend! 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-set-from! a 99))
+ (and (eq? a (array-amend! a 99))
(array-equal? a #0(99))))))