Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #15260

Re: Finding a function within an arbitrary expression

From amannucci <Anthony.J.Mannucci@jpl.nasa.gov>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Finding a function within an arbitrary expression
Date 2013-07-30 03:14 +0000
Message-ID <kt7b2v$djs$1@smc.vnet.net> (permalink)
References <20130630072942.2AF536A20@smc.vnet.net> <kqrj00$4ao$1@smc.vnet.net>
Organization Time-Warner Telecom

Show all headers | View raw


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. 

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Re: Finding a function within an arbitrary expression Bob Hanlon <hanlonr357@gmail.com> - 2013-07-01 09:43 +0000
  Re: Finding a function within an arbitrary expression amannucci <Anthony.J.Mannucci@jpl.nasa.gov> - 2013-07-30 03:14 +0000

csiph-web