MathGroup Archive 1993

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

Search the Archive

pattern matching

  • To: mathgroup at yoda.physics.unc.edu (Mathematica mailing list)
  • Subject: pattern matching
  • From: nachbar at merck.com
  • Date: Thu, 22 Jul 1993 08:31:29 -0500 (EDT)

hi,

i trying to write a function that has a calling sequence similar to 
FindMinimum[expr, {x,x0},{y,y0},..., opt1->val1,opt2->val2,...] where
at least {x,x0} must be included and none of the options are required.

so i tried:

In[1]:= MyFunc[data_, k:{_,_}.., opts:Rule[_,_]...]:=
        Module[{},
                Print[data] ;
                Print[{k}] ;
                Print[{opts}]
                ]

In[2]:= MyFunc[{{1,2,3},{4,5,6},{7,8,9}}, {5,4},{5,3},{6,5},{6,4}]

Out[2]= MyFunc[{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}, {5, 4}, {5, 3}, {6, 5},

>    {6, 4}]

In[3]:= MyFunc[{{1,2,3},{4,5,6},{7,8,9}}, {5,4},{5,3},{6,5},{6,4},
                Weighting->True]
{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}
{{5, 4}, {5, 3}, {6, 5}, {6, 4}}
{Weighting -> True}

In[4]:=

as you can see, it only works when options are included.
any ideas of what i've missed?\

bob

-- 
Dr. Robert B. Nachbar | Merck Research Laboratories | 908/594-7795
nachbar at merck.com     | R50S-100                    | 908/594-4224 FAX
                      | PO Box 2000                 |
                      | Rahway, NJ 07065            |







  • Prev by Date: NIntegrate vs. N[Integrate]
  • Next by Date: Summary: Performance of numerical functions decreases with time
  • Previous by thread: Re: NIntegrate vs. N[Integrate]
  • Next by thread: Summary: Performance of numerical functions decreases with time