[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 08/16: Rename array-set-from!, scm_array_set_from_x to a
From: |
Daniel Llorens |
Subject: |
[Guile-commits] 08/16: Rename array-set-from!, scm_array_set_from_x to array-amend!, scm_array_amend_x |
Date: |
Fri, 13 Nov 2015 14:30:49 +0000 |
lloda pushed a commit to branch lloda-array-support
in repository guile.
commit bc018aa7e52eed4e523e497cfb80fd47b0555d9c
Author: Daniel Llorens <address@hidden>
Date: Wed Feb 11 19:32:02 2015 +0100
Rename array-set-from!, scm_array_set_from_x to array-amend!,
scm_array_amend_x
---
doc/ref/api-compound.texi | 12 +++++++-----
libguile/arrays.c | 18 +++++++++---------
libguile/arrays.h | 2 +-
test-suite/tests/arrays.test | 16 ++++++++--------
4 files changed, 25 insertions(+), 23 deletions(-)
diff --git a/doc/ref/api-compound.texi b/doc/ref/api-compound.texi
index 4823c06..01385a9 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
address@hidden {Scheme Procedure} array-set-from! array x idx @dots{}
address@hidden {C Function} scm_array_set_from_x (array, x, idxlist)
address@hidden {Scheme Procedure} array-amend! array x idx @dots{}
address@hidden {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
address@hidden(apply array-set-from! array x indices)} is equivalent to
address@hidden(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 99ed18a..04896f5 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 @address@hidden ..., ...]\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 @address@hidden ..., ...]\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 @address@hidden ..., ...] 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 6399333..bd216ae 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 dfcd6f8..c6027c2 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))))))
- [Guile-commits] 01/16: Avoid unneeded internal use of array handles, (continued)
- [Guile-commits] 01/16: Avoid unneeded internal use of array handles, Daniel Llorens, 2015/11/13
- [Guile-commits] 04/16: Reuse SCM_BYTEVECTOR_TYPED_LENGTH in scm_array_get_handle, Daniel Llorens, 2015/11/13
- [Guile-commits] 02/16: Remove scm_from_contiguous_array, Daniel Llorens, 2015/11/13
- [Guile-commits] 05/16: Compile in C99 mode, Daniel Llorens, 2015/11/13
- [Guile-commits] 06/16: New functions array-from, array-from*, array-set-from!, Daniel Llorens, 2015/11/13
- [Guile-commits] 07/16: Tests & doc for array-from, array-from*, array-set-from!, Daniel Llorens, 2015/11/13
- [Guile-commits] 10/16: Fix compilation of rank 0 typed array literals, Daniel Llorens, 2015/11/13
- [Guile-commits] 09/16: Don't use array handles in scm_c_array_rank, Daniel Llorens, 2015/11/13
- [Guile-commits] 03/16: Unuse array 'contiguous' flag, Daniel Llorens, 2015/11/13
- [Guile-commits] 11/16: Remove deprecated array functions, Daniel Llorens, 2015/11/13
- [Guile-commits] 08/16: Rename array-set-from!, scm_array_set_from_x to array-amend!, scm_array_amend_x,
Daniel Llorens <=
- [Guile-commits] 12/16: Speed up for multi-arg cases of scm_ramap functions, Daniel Llorens, 2015/11/13
- [Guile-commits] 13/16: Remove deprecated and unused generalized-vector functions, Daniel Llorens, 2015/11/13
- [Guile-commits] 14/16: Do not use array handles in scm_vector, Daniel Llorens, 2015/11/13
- [Guile-commits] 16/16: Draft documentation for (array-for-each-cell), Daniel Llorens, 2015/11/13
- [Guile-commits] 15/16: Draft of (array-for-each-cell), Daniel Llorens, 2015/11/13