From af4f861210c83b08b1ddc503fdaa2acc9949a0fd Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Mon, 29 May 2006 21:54:13 +0000 Subject: [PATCH] * eq.c (scm_equal_p): Use scm_array_equal_p explicitely when one of the arguments is a array. This allows vectors to be equal to one-dimensional arrays. * tests/unif.test ("vector equal? one-dimensional array"): New. --- NEWS | 4 ++++ libguile/ChangeLog | 6 ++++++ libguile/eq.c | 5 +++++ test-suite/ChangeLog | 4 ++++ test-suite/tests/unif.test | 8 ++++++++ 5 files changed, 27 insertions(+) diff --git a/NEWS b/NEWS index 27b41223b..6b7ad7c52 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,10 @@ Each release reports the NEWS in the following sections: Changes in 1.8.1: +* Changes to Scheme functions and syntax + +** A one-dimenisonal array can now be 'equal?' to a vector. + * Bug fixes. ** array-set! with bit vector. ** string + + * eq.c (scm_equal_p): Use scm_array_equal_p explicitely when one + of the arguments is a array. This allows vectors to be equal to + one-dimensional arrays. + 2006-05-29 Marius Vollmer * throw.c (scm_ithrow): When looking for the jmpbuf, first test diff --git a/libguile/eq.c b/libguile/eq.c index 4513b6b32..71d1acfa1 100644 --- a/libguile/eq.c +++ b/libguile/eq.c @@ -257,6 +257,11 @@ SCM_PRIMITIVE_GENERIC_1 (scm_equal_p, "equal?", scm_tc7_rpsubr, && SCM_COMPLEX_IMAG (x) == 0.0); } + /* Vectors can be equal to one-dimensional arrays. + */ + if (SCM_I_ARRAYP (x) || SCM_I_ARRAYP (y)) + return scm_array_equal_p (x, y); + return SCM_BOOL_F; } switch (SCM_TYP7 (x)) diff --git a/test-suite/ChangeLog b/test-suite/ChangeLog index 386eda17e..53b0662b5 100644 --- a/test-suite/ChangeLog +++ b/test-suite/ChangeLog @@ -1,3 +1,7 @@ +2006-05-30 Marius Vollmer + + * tests/unif.test ("vector equal? one-dimensional array"): New. + 2006-05-28 Marius Vollmer * tests/ports.test, tests/filesys.test: Delete test file after all diff --git a/test-suite/tests/unif.test b/test-suite/tests/unif.test index a5be1826f..2a0048483 100644 --- a/test-suite/tests/unif.test +++ b/test-suite/tests/unif.test @@ -512,3 +512,11 @@ (begin (array-set! a -128 0) (= -128 (uniform-vector-ref a 0))))))) + +;;; equal? with vector and one-dimensional array + +(pass-if "vector equal? one-dimensional array" + (equal? (make-shared-array #2((a b c) (d e f) (g h i)) + (lambda (i) (list i i)) + '(0 2)) + #(a e i)))