MathGroup Archive 2013

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

Search the Archive

Re: Finding a function within an arbitrary expression


On Monday, July 1, 2013 2:43:28 AM UTC-7, Bob Hanlon wrote:
> data = {3*u[1, 0], u[0, 0]/10., 1/u[1, 0], f[u[1, 0]]};
> 
> 
> data2 = Select[data, MemberQ[#, u[1, 0]] &]
> 
> 
> {3*u[1, 0], 1/u[1, 0], f[u[1, 0]]}
> 
> 
> Some other methods: [snip]
> 
> 
> Bob Hanlon
> 
> 

Your top example is a good way to do it. I am completely mystified, however. I originally tried to do this with Cases, but that did not work because of expression levels. I did not specify an expression level when using Cases. 

You do not specify the level in your MemberQ call, but it works. Yet, this does not work:
MemberQ[{3*u[1, 0]}, u[1, 0]] gives False
but 
MemberQ[{3*u[1, 0]}, u[1, 0],Infinity] gives True

So why don't you need a level spec in your example (definition of data2)? It's as if creating a lambda function automatically inserts the level spec. 



  • Prev by Date: Re: Incorrect (unexpected) output from TransformedField
  • Next by Date: Re: Variable transformations
  • Previous by thread: Re: Finding a function within an arbitrary expression
  • Next by thread: Re: Finding a function within an arbitrary expression