Re: Finding a function within an arbitrary expression

• To: mathgroup at smc.vnet.net
• Subject: [mg131357] Re: Finding a function within an arbitrary expression
• From: "Dr. Wolfgang Hintze" <weh at snafu.de>
• Date: Mon, 1 Jul 2013 05:48:18 -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: <kqomkf\$p7b\$1@smc.vnet.net>

```Am Sonntag, 30. Juni 2013 09:27:11 UTC+2 schrieb amannucci:
> 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.

Hello,

You could use this function which looks even for a general pattern "pat" rather than just u[1,0]

f[pat_] = Complement[#1, Select[#1, FreeQ[#1, pat] & ]] &

Examples

x = {3*u[1, 0], u[0, 0]/10., 1/u[1, 0], u[1, 0]/2., b*Sqrt[u[1, 0]]}

In[83]:= f[u[1, 0]][x]
Out[83]= {1/u[1, 0], b*Sqrt[u[1, 0]], 0.5*u[1, 0], 3*u[1, 0]}

In[82]:= f[u[0, 0]][x]
Out[82]= {0.1*u[0, 0]}

Best regards,
Wolfgang

```

• Prev by Date: Re: Finding a function within an arbitrary expression
• Next by Date: Constraint definition is not valid: WHY?
• Previous by thread: Re: Finding a function within an arbitrary expression
• Next by thread: Re: Finding a function within an arbitrary expression