Re: Finding a function within an arbitrary expression
- To: mathgroup at smc.vnet.net
- Subject: [mg131362] Re: Finding a function within an arbitrary expression
- From: Bob Hanlon <hanlonr357 at gmail.com>
- Date: Mon, 1 Jul 2013 05:49:58 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-outx@smc.vnet.net
- Delivered-to: mathgroup-newsendx@smc.vnet.net
- References: <20130630072942.2AF536A20@smc.vnet.net>
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: data2 = Cases[data, _?(MemberQ[#, u[1, 0]] &)] = DeleteCases[data, _?(! MemberQ[#, u[1, 0]] &)] = Select[data, ! FreeQ[#, u[1, 0]] &] = Cases[data, _?(! FreeQ[#, u[1, 0]] &)] = DeleteCases[data, _?(FreeQ[#, u[1, 0]] &)] = data[[First /@ Position[data, u[1, 0]]]] True Bob Hanlon On Sun, Jun 30, 2013 at 3:29 AM, amannucci <Anthony.J.Mannucci at jpl.nasa.gov>wrote: > I am trying to figure out what that pattern is for the following. The > difficulty here is that I can think textually, but not in Mathematica > patterns. > > I am looking for a function u[1,0] within a list of expressions. The > function might not be defined yet. For example, a list of expressions might > be: > > {3*u[1,0], u[0,0]/10., 1/u[1,0], ...} > > I want to find all the expressions that have the function u[1,0] in it. > There is certainly a way to do this "textually". How would one do this with > patterns? Is it possible? Thank you. > > >