MathGroup Archive 1997

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

Search the Archive

Re: Sequence is funny !


Gilles BARBIER wrote:
> 
>      For some people who like to understand the internal mechanism
>      of Mathematica, I give them this little problem a friend sent to me :
> 
>      Why Table[i,{i,Sequence[1,3]}] gives {1,2,3,4} instead of {1,2,3} !!
> 
>      That's not a bug, I even have an explanation,if you are interested.
> 
>      Hope it's fun,
> 
>      Gilles.

I have no explanation, but I will throw some more information into the
pot.

Table[i,{i,Sequence[1,n]}] returns {1,2,3...,n+1}
Table[i,{i,1,n}]           returns  {1,2,3,...n}
Table[i,{i,Sequence[0,n]}] returns {1,2,3,...n}
Table[i,{i,0,n}]           returns {0,1,2,3...n}

Since Sequence is advertised as:

"Sequence[expr1, expr2, ... ] represents a sequence of arguments to be
spliced automatically into any function."

The above behavior IS a bug in my opinion regardless of how you can
explain it with internal structure etc.  The command does not do as
advertised=> a bug.


  • Prev by Date: RE: FindRoot
  • Next by Date: Re: := vs. =
  • Previous by thread: debugging
  • Next by thread: Re: Sequence is funny !