Re: How do I test for existence of a list element?
- To: mathgroup at smc.vnet.net
- Subject: [mg112674] Re: How do I test for existence of a list element?
- From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
- Date: Sun, 26 Sep 2010 02:43:26 -0400 (EDT)
- References: <email@example.com>
You could test whether the index you are using is larger than the length of the list using Length[ ], but it would seem like bad programming if such an index could accidentally pop up. Cheers -- Sjoerd On Sep 25, 8:21 am, Joseph Gwinn <joegw... at comcast.net> wrote: > I have an application where I am bouncing around in a list, and may > accidentally ask for an element beyond the end of the list, which causes > Mathematica to complain and balk, preventing completion. > > Is there any way to test for the existence of a list element without > provoking complaint or balking should the list item fail to exist? > > Thanks, > > Joe Gwinn