MathGroup Archive 2010

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

Search the Archive

Re: How do I test for existence of a list element?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg112753] Re: How do I test for existence of a list element?
  • From: Ray Koopman <koopman at sfu.ca>
  • Date: Wed, 29 Sep 2010 04:14:38 -0400 (EDT)
  • References: <i7k4d7$lha$1@smc.vnet.net> <i7pp98$lds$1@smc.vnet.net>

On Sep 27, 2:48 am, "andre.robin3" <andre.rob... at wanadoo.fr> wrote:
> I recently had the same problem, but for a more general case : How to
> test the existence of a deeply embedded element in a ragged structure ?
>
> Say that the position of the element is specified by : list={i,j,k ..}
>
> my solution was something like :
>
> existenceTestQ[exp_, list_] := Module[{res},
> res = False;
> ReplacePart[exp, list :> (res = True)];
> res
> ]
>
> may be not elegant, but sufficient

This should do the same thing:

isQ[exp_, list_] := MemberQ[ Position[
  exp, _, {Length@list}, Heads->False], list ]


  • Prev by Date: Poisson's integral formula doesn't work
  • Next by Date: Difficulty with Interpolation / FunctionInterpolation
  • Previous by thread: Re: How do I test for existence of a list element?
  • Next by thread: Re: How do I test for existence of a list element?