MathGroup Archive 1993

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

Search the Archive

Length feature

  • To: mathgroup at (Mathematica User's Group)
  • Subject: Length feature
  • From: Keith Clay <clay at>
  • Date: Fri, 20 Aug 93 1:30:52 MDT

Okay, somebody explain it to me.  I can't fathom the following feature
of the Length function:

In[1]:= s = 5
Out[1]= 5

In[2]:= t = x
Out[2]= x

In[3]:= sum = s+t
Out[3]= 5 + x			(* so far, so good *)

In[4]:= Length[sum]
Out[4]= 2			(* still looks good *)

In[5]:= Length[t]
Out[5]= 0			(* zero? *)

In[6]:= Length[s]
Out[6]= 0			(* zero? *)

This makes it impossible to write code that reads

Do[ blah; blah; blah,  {j, 1, Length[expr]} ]

without defining something like
	MyLength[expr_]:= Max[ 1, Length[expr] ]
which works but seems rather silly.

Is there a reason why Length[t] = 0?

clay at

  • Prev by Date: Re: Mathematica courses in College
  • Next by Date: Compliments on the mathsource
  • Previous by thread: Review Materials for numerical analysis
  • Next by thread: Compliments on the mathsource