MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Default argument and conditional pattern question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg61812] Re: [mg61796] Default argument and conditional pattern question
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Mon, 31 Oct 2005 01:17:06 -0500 (EST)
  • Reply-to: hanlonr at cox.net
  • Sender: owner-wri-mathgroup at wolfram.com

callLevelAndPrintResults[list_List, lev_List:{1}] :=
    Module[{}, some stuff] /;
      Length[lev] == 1 && Depth[lev] == 2;


Bob Hanlon

> 
> From: "Matt" <anonmous69 at netscape.net>
To: mathgroup at smc.vnet.net
> Date: 2005/10/30 Sun AM 12:43:28 EDT
> Subject: [mg61812] [mg61796] Default argument and conditional pattern question
> 
> 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
> 
> 


  • Prev by Date: Re: this is ridiculous...
  • Next by Date: call notebook
  • Previous by thread: Default argument and conditional pattern question
  • Next by thread: SymbolName question