arrays

For the Compleat Fan
Locked
Sammo
Posts: 180
Joined: Sat Dec 06, 2003 6:11 pm
Location: Loveland, Colorado USA

arrays

Post by Sammo »

A couple of array questions:

1) Is 'length' supposed to work directly on arrays? It seems to work but other list-related functions (e.g., 'first') understandably don't. The 'length' entry in manual version 7.5.2 refers to lists and strings but not arrays.

(set 'a (array 5 5))
(length (array-list a)) => 5
(length a) => 5

2) Is there or could there be a way to determine an array's structure -- something like:

Code: Select all

(define (array-dims a , dims)
    (while (array? a)
        (push (length (array-list a)) dims)
        (setq a (nth 0 a)) )
    (reverse dims) )
For example:

(set 'a (array 2 3 '(("magoo"))) )
(array-dims a) => (2 3)

Locked