Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Re: Head logic

  • To: mathgroup at smc.vnet.net
  • Subject: [mg97074] Re: Head logic
  • From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
  • Date: Wed, 4 Mar 2009 07:14:52 -0500 (EST)
  • References: <goj2bk$2qu$1@smc.vnet.net>

It's the same for every comparison of heads, e.g. Times == Plus return
unevaluated as well. Not sure why this is so, but I guess it would be
difficult to provein general that two functions are exactly functional
equivalent or not.

You can force evaluation by using === or =!=. Those functions check
whether the comparants are literally the same.

For testing of heads you could use expressions described in

tutorial/PuttingConstraintsOnPatterns

and

tutorial/SpecifyingTypesOfExpressionInPatterns

Cheers -- Sjoerd

On Mar 3, 12:55 pm, car... at colorado.edu wrote:
> Entering
>
>    ClearAll[r];
>    Head[r]
>    Head[r]!=Symbol
>    Head[r]==Symbol
>
> give Symbol, False and True as expected. But
>
>    Head[r]==Integer
>
> evaluates to Symbol==Integer. Why not False?
> Head[r] is certainly not Integer. Likewise
>
>   r=4;
>   Head[r]==Integer
>   Head[r]!=Symbol
>   Head[r]==Symbol
>
> give True (correct) but  Integer!=Symbol and Integer==Symbol.
> Why not True and False?



  • Prev by Date: Re: "Do What I Mean" - a suggestion for improving
  • Next by Date: Re: Looking to time how long a command takes in mathematica 6 tia
  • Previous by thread: Re: Head logic
  • Next by thread: Re: Head logic