Pattern Matching
- To: mathgroup at smc.vnet.net
- Subject: [mg49003] Pattern Matching
- From: "Bruce W. Colletti" <bcolletti at compuserve.com>
- Date: Mon, 28 Jun 2004 04:13:47 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
This command (built from recent traffic) extracts the quadratic's coefficients and exponents: Cases[4x + x^2, c_.*x^n_. -> {c,n}] {{4,1}, {1,2}} As I understand it, the symbol "_." uses the global default value for the given variable, a value that can be set using Default. Question: For the specific (illustrative) problem above, how would I set (using Default[ ]) different default values for c and n? Or must I do something like: Cases[4x + x^2, (c_:5)*x^(n_:7) -> {c,n}] Thanks. Bruce
- Follow-Ups:
- Re: Pattern Matching
- From: Andrzej Kozlowski <akoz@mimuw.edu.pl>
- Re: Pattern Matching
- From: DrBob <drbob@bigfoot.com>
- Re: Pattern Matching