MathGroup Archive 2005

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

Search the Archive

Re: To be or not to be...


Ingolf Dahl wrote:

> 
> To Mathgroup,
> 
> Try the following commands in order:
> 
> b = Sequence[]
> 
> b == Sequence[]
> 
> b != Sequence[]
> 
> b === Sequence[]
> 
> b =!= Sequence[]
> 
> The four last lines all evaluate to "True" for me. Quite amazing!

Was that a question? The reason is that Equal[], SameQ[], UnsameQ[],
Unequal[] all return True if called with zero (or one) arguments, which is
in fact what you are doing, since Sequence[] does what it is meant to do,
no matter whether the head of the expression is List, Equal or UnsameQ. If
you want to test whether something is a Sequence[] or not you will need
another approach, a simple way is to use a head with Attribute
SequenceHold:

SetAttributes[ccc, SequenceHold]
ccc[b] =!= ccc[Sequence[]]
ccc[b] === ccc[Sequence[]]

which will give the results you probably expected...

albert


  • Prev by Date: Re: ((a&&b)||c)==((a||c)&&(b||c))
  • Next by Date: Re: feature request: invert plot axes
  • Previous by thread: Re: Re: To be or not to be...
  • Next by thread: Re: To be or not to be...