Re: Pattern matching in functions
- To: mathgroup at smc.vnet.net
- Subject: [mg54454] Re: [mg54379] Pattern matching in functions
- From: DrBob <drbob at bigfoot.com>
- Date: Sun, 20 Feb 2005 00:11:12 -0500 (EST)
- References: <200502190732.CAA06160@smc.vnet.net>
- Reply-to: drbob at bigfoot.com
- Sender: owner-wri-mathgroup at wolfram.com
Something like this?
Cases[l^4*a[b][l] + l*a[c][l], a[x_][y_] -> x, {0, Infinity}]
{b,c}
or
Cases[l^4*a[b][l] + l*a[c][l], a[x_] -> x, {0, Infinity}, Heads -> True]
{b, c}
or
Cases[l^4*a[b][l] + l*a[c][l], a[x_][y_] -> {x, y}, {0, Infinity}]
{{b,l},{c,l}}
Bobby
On Sat, 19 Feb 2005 02:32:49 -0500 (EST), Maximilian Ulbrich <mulbrich at berkeley.edu> wrote:
> Hi,
>
> I would like to find subexpressions using Cases.
> In the following case, I expected to find a[b] and a[c] and therefore
> get {b,c} as the result. However, I get {l,l}.
> What happens and how can I solve this?
>
> Cases[l^4*a[b][l] + l*a[c][l], x_a[y_] -> y, {0, Infinity}]
>
> Thanks,
> Max
>
>
>
>
--
DrBob at bigfoot.com
www.eclecticdreams.net
- References:
- Pattern matching in functions
- From: Maximilian Ulbrich <mulbrich@berkeley.edu>
- Pattern matching in functions