MathGroup Archive 2005

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

Search the Archive

Re: Re: Zero or one


On 10 Dec 2005, at 20:02, dkr wrote:

> The following definitions are not equivalent:
>
> In[1]:=
> optional1[expr_] := expr | ___ ? (Length[{#}] == 0&);
> optional2[expr_]:=expr|___?(#==Null&);
>
> In[3]:=
> MatchQ[{1,,3},{1,optional1[2],3}]
> Out[3]=
> False
> In[4]:=
> MatchQ[{1,,3},{1,optional2[2],3}]
> Out[4]=
> True
>

Yes, I never considered the possibility of a List with missing  
entries (explicit Null). The reason why the definitions are not  
equivalent is that Null vanishes only when it is the final value  
returned by a computation, so

Length[{Null}]

1

Of course it is not entirely obvious which interpretation of "0 or 1"  
is more correct in the case of something like {1, ,3}. Would you say  
that the second entry ("nothing") is correctly described as "0 or 1  
of something"?  Or is "Null", a "positive nothingness" and quite  
different from the simple "absence of anything"? Actually, in  
Mathematica it is sometime one and sometime the other. But just in  
case anybody takes this too seriously I believe philosophical  
considerations of the nature of nothingness are best left to writers  
like Stanislaw Lem ;-)

Andrzej Kozlowski



  • Prev by Date: Re: A list of numbers without "73"
  • Next by Date: Re: functional programming
  • Previous by thread: Re: Zero or one
  • Next by thread: Bug in Graphics output of Circle primitive?