chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] (array-strict? (make-array '#() 7)) ; should return


From: Kon Lovett
Subject: Re: [Chicken-users] (array-strict? (make-array '#() 7)) ; should return #t right?
Date: Tue, 4 Sep 2007 18:23:54 -0700


On Sep 4, 2007, at 5:38 PM, Terrence Brannon wrote:

(require-extension array-lib)

(array-strict? (make-array '#() 7)) ; should return #t


However, it returns false... it seems to be a strict array to me.

From SRFI-63:
"... make-array ...
... The implementation-dependent type of the returned array will be the same as the type of prototype; except if that would be a vector or string with rank not equal to one, in which case some variety of array will be returned."

So '(make-array '#() 7)' returns a vector, which is not a strict array.


I do need for a 1-dimensional structure created by make-array to be
testable by some predicate for a procedure I have written called
Shape, analagous to the J verb by the same name:

#;47> (array-strict? (Shape '(8) 5))
#f
#;48> (array-strict? (Shape '(1 8) 5))
#t

In J, both of these are arrays. The first is a rank-1 array and the
second is a rank-2 array.

They are in SRFI-63 as well.


This is the Shape procedure:


(define (Shape dim-list . data)
(let* ([dimension-list (if (list? dim-list) dim-list (list dim- list))]
         [prototype '#()]
         [dimensions (apply make-array-dimensions dimension-list)]
         [cardinality (apply * dimension-list)]
         [data-size (lambda () (length data))]
         [list-logic (lambda (L)
                       (cond
                        ((= (data-size) cardinality) data)
((> (data-size) cardinality) (take data cardinality))
                        ((< (data-size) cardinality)
(take (apply circular-list data) cardinality))))]
         [data* (if (list? data)
                    (list-logic data)
                    (make-list cardinality data))]
         [vektor (list->vector data*)])
    (apply vector->array vektor prototype dimension-list)))


_______________________________________________
Chicken-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/chicken-users





reply via email to

[Prev in Thread] Current Thread [Next in Thread]