MathGroup Archive 2002

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

Search the Archive

Help: Why no output?

  • To: mathgroup at
  • Subject: [mg34941] Help: Why no output?
  • From: kzhang at (Kezhao Zhang)
  • Date: Fri, 14 Jun 2002 02:38:44 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

The behavior of the following function is puzzling to me:

In[1]:=f[x_, n___Integer] := If[Length[{n}] == 1, n  , Length[x]]
In[2]:=f[0.5]  (* Nothing returned. *)
In[3]:=f[{1,2}] (* Nothing returned. The length of x should be
returned *)
(* However, with the modification to f, everything works as intended
In[4]:=f[x_, n___Integer] := If[Length[{n}] == 1, 1*n  , Length[x]]

Could anyone help me understand why changing n to (1*n) in the If[]
statement makes such difference? Why doesn't f[] defined in the In[1]

Thanks for your help.

Kezhao Zhang

  • Prev by Date: Export color bug in Mac OS X?
  • Next by Date: Re: Nonlinear Programming?
  • Previous by thread: Export color bug in Mac OS X?
  • Next by thread: Re: Help: Why no output?