summaryrefslogtreecommitdiff
path: root/libguile/arrays.c
diff options
context:
space:
mode:
authorDaniel Llorens <daniel.llorens@bluewin.ch>2013-04-10 15:11:33 +0200
committerAndy Wingo <wingo@pobox.com>2014-02-06 21:40:38 +0100
commita6f8d3ddd833260bed88709f73ab9cb380f7afa0 (patch)
tree61aaf84f363c9146bad53850174e2869a6afb503 /libguile/arrays.c
parentee2386952149ceb31cb6d32c58be90f1d5c32c30 (diff)
downloadguile-a6f8d3ddd833260bed88709f73ab9cb380f7afa0.tar.gz
Don't use scm_is_generalized_vector in transpose-array
* libguile/arrays.c (scm_transpose_array) - Use scm_c_array_rank(), which contains an implicit is_array test. - Handle the rank 0 case. * test-suite/tests/arrays.test - Add test for rank 0 case. - Add failure test for non array argument.
Diffstat (limited to 'libguile/arrays.c')
-rw-r--r--libguile/arrays.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/libguile/arrays.c b/libguile/arrays.c
index 0d39e8eae..a8b62b2b0 100644
--- a/libguile/arrays.c
+++ b/libguile/arrays.c
@@ -477,20 +477,22 @@ SCM_DEFINE (scm_transpose_array, "transpose-array", 1, 0, 1,
SCM_VALIDATE_REST_ARGUMENT (args);
SCM_ASSERT (SCM_HEAP_OBJECT_P (ra), ra, SCM_ARG1, FUNC_NAME);
- if (scm_is_generalized_vector (ra))
+ switch (scm_c_array_rank (ra))
{
+ case 0:
+ if (!scm_is_null (args))
+ SCM_WRONG_NUM_ARGS ();
+ return ra;
+ case 1:
/* Make sure that we are called with a single zero as
- arguments.
+ arguments.
*/
if (scm_is_null (args) || !scm_is_null (SCM_CDR (args)))
SCM_WRONG_NUM_ARGS ();
SCM_VALIDATE_INT_COPY (SCM_ARG2, SCM_CAR (args), i);
SCM_ASSERT_RANGE (SCM_ARG2, SCM_CAR (args), i == 0);
return ra;
- }
-
- if (SCM_I_ARRAYP (ra))
- {
+ default:
vargs = scm_vector (args);
if (SCM_SIMPLE_VECTOR_LENGTH (vargs) != SCM_I_ARRAY_NDIM (ra))
SCM_WRONG_NUM_ARGS ();
@@ -540,8 +542,6 @@ SCM_DEFINE (scm_transpose_array, "transpose-array", 1, 0, 1,
scm_i_ra_set_contp (res);
return res;
}
-
- scm_wrong_type_arg_msg (NULL, 0, ra, "array");
}
#undef FUNC_NAME