Patterns and default arguments
- To: mathgroup at smc.vnet.net
- Subject: [mg28113] Patterns and default arguments
- From: Jeff DuMonthier <jeff at lheapop.gsfc.nasa.gov>
- Date: Sat, 31 Mar 2001 02:58:48 -0500 (EST)
- Organization: NASA Goddard Space Flight Center (skates.gsfc.nasa.gov)
- Sender: owner-wri-mathgroup at wolfram.com
I am trying to combine a pattern with a default argument in a delayed
set expression and it is not working.
I can make a default argument work like this: f[x1_, x2_List:{}]:=...
And the pattern works like this: f[x1_, x2:{_Integer...}]:=
But if I combine the two like this: f[x1_, x2:{_Integer...}:{}]:=
Mathematica accepts it without error and the pattern expression works
but the default does not.
Am I using the wrong syntax or can the two just not be combined?
Also, is there a way to specify a pattern for aguments to something
defined as a function (i.e. 'Function[...]') rather than a delayed set?
I have to use 'Function' or ()& in order for the head to be 'Function'
rather than 'Symbol'.
-Jeff DuMonthier