Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: function to check if array is empty

  • To: mathgroup at smc.vnet.net
  • Subject: [mg88317] Re: [mg88313] function to check if array is empty
  • From: "Adriano Pascoletti" <adriano.pascoletti at gmail.com>
  • Date: Thu, 1 May 2008 06:27:08 -0400 (EDT)
  • References: <200805010722.DAA26200@smc.vnet.net>

Will,
a null row is a list of one or more 0's {(0)..} and a null matrix is a list
of one or more null rows {{(0)..}..}, so

In[4]:= MatchQ[X, {{(0) ..} ..}]
Out[4]= True

and

ArrayEmpty=MatchQ[#, {{(0) ..} ..}]&

If you want to match both exact and approximate 0's replace (0).. with
(0|0.)..


Adriano Pascoletti

On Thu, May 1, 2008 at 9:22 AM, will parr <willpowers69 at hotmail.com> wrote:

> Dear Math Forum,
>
> this probably already exists, but I can't find it anywhere:
>
> is there a function that will check if an array is empty?
>
> i'm looking for a function to return either True (or 1), or False (or 0)
> when it checks an array. eg:
>
> X = Array[0 &, {3, 3}]
>
> then test with function (called ArrayEmpty, for example)
>
> In: ArrayEmpty[X]
>
> Out: True
>
> best wishes,
>
> Will
>
>


  • Prev by Date: Re: Exact Cover
  • Next by Date: Mathematica student certification now available
  • Previous by thread: function to check if array is empty
  • Next by thread: Re: function to check if array is empty