Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: Problem with MatchQ and SameQ

  • To: mathgroup at
  • Subject: [mg56444] Re: [mg56429] Problem with MatchQ and SameQ
  • From: "Wolf, Hartmut" <Hartmut.Wolf at>
  • Date: Tue, 26 Apr 2005 01:32:44 -0400 (EDT)
  • Sender: owner-wri-mathgroup at


>-----Original Message-----
>From: Miguel [mailto:mbli at] 
To: mathgroup at
>Sent: Monday, April 25, 2005 7:31 AM
>Subject: [mg56444] [mg56429] Problem with MatchQ and SameQ
>Normally I operate with Mathematica 5.0. The functions MatchQ and
>SameQ work well  in a notebook but don't it in a programm.
>For example,in a notebook
>In[1]: f[x_,y_,option_]:=
>  If[MatchQ[option,SolutionForm->Explicit],x+y,
>    If[MatchQ[option,SolutionForm->Implicit],x*y],Print["Eror"]]
>It works well.
>In my programm,


you are looking at the wrong place! MatchQ and SameQ won't account for
that, more probably ProgamU.

I guess your problem lies with your package (which you did not show): I
suppose, there you do use local definitions for Implicit, Explicit, yet
when you call the function, globals. (You have to define them outside of
the private part of your package; look into a standard package for an

BTW: The standard idiom for recognizing Options is this:

f[x_, y_, options___] := Module[{sForm},
    sForm = SolutionForm /. Flatten[{options}];
    Switch[sForm, Explicit, x + y,
      Implicit, x*y,
      _, Print["Missing Option SolutionForm"]]]

This is much more robust.

Also: consider defining default options for f (consult the book).

Hartmut Wolf

  • Prev by Date: Re: Re: to those interested in * finding * Mathematica help
  • Next by Date: Re: Shell script and Mathematica.
  • Previous by thread: Problem with MatchQ and SameQ
  • Next by thread: Re: Problem with MatchQ and SameQ