From: ······@bingvaxu.cc.binghamton.edu
Subject: another array question.
Date: 
Message-ID: <1991Jul17.170046.29063@newserve.cc.binghamton.edu>
Hi, 

Is there a way to test an array for null-ness (ie, all it's elements
are null) in a single shot - as we can do for a list!


Since I don't know such macro or function, so currently i am doing
this:

(setf my-array (make-array n));where n is any dimension
(setf counter 0)

(defun null-test ()
 (cond ((= counter n) 't)
       ((not (null (aref my-array counter))) 'nil)
   (t  (incf counter)(null-test))))


I will appreciate if anyone has a better/faster way of doing it.

(I wish i could do: (null my-array) but can't)

Pls.email

Thanks

From: Peter Benson
Subject: Re: another array question.
Date: 
Message-ID: <PAB.91Jul17130317@challenger.lucid.com>
either 
(every #'null my-array)

or, for added speed if you know it's a simple vector:

(dotimes (i (length my-array) t)
  (when (null (svref my-array i)) (return nil)))

A compiler really ought to optimize every, but I'lll be most don't.

-ptr-
From: Barry Margolin
Subject: Re: another array question.
Date: 
Message-ID: <1991Jul17.221341.22446@Think.COM>
In article <······················@newserve.cc.binghamton.edu> ······@bingvaxu.cc.binghamton.edu () writes:
>Is there a way to test an array for null-ness (ie, all it's elements
>are null) in a single shot - as we can do for a list!

(every #'null <sequence>)

will do it when <sequence> is a list or vector.  If you want it to work for
multidimensional arrays as well you'll have to do more work (the simplest
way is to displace a 1-d array to the multi-d array, and then use EVERY on
the displaced array).

>(I wish i could do: (null my-array) but can't)

That wouldn't work for a list, either.  That tells you whether the list is
zero-length, not whether every element of the list is null.  There's a big
difference.
-- 
Barry Margolin, Thinking Machines Corp.

······@think.com
{uunet,harvard}!think!barmar