MathGroup Archive 2002

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

Search the Archive

Re: How build a ?TestFuntion that applied to a list gives onlythe elements that are function of x

  • To: mathgroup at smc.vnet.net
  • Subject: [mg33005] Re: [mg32995] How build a ?TestFuntion that applied to a list gives onlythe elements that are function of x
  • From: Tomas Garza <tgarza01 at prodigy.net.mx>
  • Date: Mon, 25 Feb 2002 01:31:22 -0500 (EST)
  • References: <200202230738.CAA02629@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

I guess one possibility would be along the following lines:

In[31]:=
lst = {Sin[a*x], a*x, Sqrt[b*y], b, y, x^2}
Out[31]=
{Sin[a*x], a*x, Sqrt[b*y], b, y, x^2}

In[32]:=
lststrg = ToString /@ lst
Out[32]=
{"Sin[a x]", "a x", "Sqrt[b y]", "b", "y", " 2\nx"}

In[33]:=
w = (Characters[#1] & ) /@ lststrg
Out[33]=
{{"S", "i", "n", "[", "a", " ", "x", "]"},
  {"a", " ", "x"}, {"S", "q", "r", "t", "[", "b", " ",
   "y", "]"}, {"b"}, {"y"}, {" ", "2", "\n", "x"}}

In[34]:=
Extract[lst, Position[w, {___, u_, ___} /; u == "x"]]
Out[34]=
{Sin[a*x], a*x, x^2}

Of course this will give you those elements of lst where "x" appears
explicitly, hoping that this means that such elements are thereby functions
of x. But if you have variable names where there is a character "x", this
won't work (such as bxb, for example).

Tomas Garza
Mexico City

----- Original Message -----
From: "J. Guillermo Sanchez" <guillerm at usal.es>
To: mathgroup at smc.vnet.net
Subject: [mg33005] [mg32995] How build a ?TestFuntion that applied to a list gives
onlythe elements that are function of x


>
> How build a ?TestFuntion that applied to a list give only the elements
> that are function of x
>
> Example:
>
> In[]:= {Sin[a x], b x, t, c r}/.?TestFuntion
>
> gives
>
> Out[] = {Sin[a x], b x}
>
> Thanks
>
> Guillermo Sanchez
>
>



  • Prev by Date: Re: Iterative application of FindRoot with adjusted started values
  • Next by Date: books about differential geometry
  • Previous by thread: How build a ?TestFuntion that applied to a list gives only the elements that are function of x
  • Next by thread: RE: How build a ?TestFuntion that applied to a list gives only the elements that are function of x