Default argument and conditional pattern question
- To: mathgroup at smc.vnet.net
- Subject: [mg61796] Default argument and conditional pattern question
- From: "Matt" <anonmous69 at netscape.net>
- Date: Sun, 30 Oct 2005 00:43:28 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Hello, This works (I want the second argument (if supplied) to be a list of length 1 and a depth of 2 (meaning no sublist), and if it is not supplied, I want the default value to be {1}) callLevelAndPrintResults[list_List, lev : (_List?(Length[#] == 1 && Depth[#] == 2 &)) : {1}] := Module[some stuff] Using the /; conditional construct, I could not get default values and a condition to work together. So, for example, this works: callLevelAndPrintResults[list_List, lev_List /; Length[lev] == 1] := Module[some stuff] but I couldn't figure out the syntax to get something like this to work: callLevelAndPrintResults[list_List, lev:(_List /; Length[lev] == 1):{1}] := Module[some stuff] I know it's mere semantics, but I'm trying to figure out what I can, and cannot do with these types of things. Thanks, Matt