Pattern Syntax for Alternate Heads with Default Value
- To: mathgroup at smc.vnet.net
- Subject: [mg125818] Pattern Syntax for Alternate Heads with Default Value
- From: Ben <benp84 at gmail.com>
- Date: Wed, 4 Apr 2012 04:27:25 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
I'm trying to build a unary function which accepts only arguments with two possible heads and has a default value. That is, something like the following, except that this doesn't work. Anyone know how to do this correctly? f[(x_Real | x_Integer) : 2.5] := x^2; where f[3] = 9 and f[1.5] = 2.25 and f[] = 6.25
- Follow-Ups:
- Re: Pattern Syntax for Alternate Heads with Default Value
- From: Fred Simons <f.h.simons@tue.nl>
- Re: Pattern Syntax for Alternate Heads with Default Value
- From: Christoph Lhotka <christoph.lhotka@fundp.ac.be>
- Re: Pattern Syntax for Alternate Heads with Default Value
- From: Bob Hanlon <hanlonr357@gmail.com>
- Re: Pattern Syntax for Alternate Heads with Default Value
- From: Adriano Pascoletti <adriano.pascoletti@uniud.it>
- Re: Pattern Syntax for Alternate Heads with Default Value