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: [mg88345] Re: [mg88313] function to check if array is empty
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Fri, 2 May 2008 03:44:20 -0400 (EDT)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <200805010722.DAA26200@smc.vnet.net>
  • Reply-to: murray at math.umass.edu

Your array is hardly "empty": it's full of zeros!

If what you want to do is test to see whether every entry is 0, the 
following will do it:

   And @@ Thread[0 == Flatten @ X]
]
will parr 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
> 

-- 
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305


  • Prev by Date: DSolve Issues
  • Next by Date: Re: For help about NSolve
  • Previous by thread: Re: function to check if array is empty
  • Next by thread: Re: function to check if array is empty