MathGroup Archive 2006

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

Search the Archive

RE: question on changing 'type' of numbers

  • To: mathgroup at
  • Subject: [mg69495] RE: [mg69473] question on changing 'type' of numbers
  • From: "David Park" <djmp at>
  • Date: Thu, 14 Sep 2006 06:55:44 -0400 (EDT)


You can't change the Head of anything that gives True to AtomQ. You cannot
access the stored data of an atom and in most cases this is for good reason.

However, there seem to be cases where this is only partly true. For example
with complex numbers...

AtomQ[2 + 3 I]

We can't change the Head

Head[List @@ (2 + 3 I)]

but we can certainly access the parts

2 + I 3 /. Complex[a_, b_] -> {a, b}
{2, 3}

Maybe others will point out other 'in between' objects.

David Park
djmp at

From: Nasser Abbasi [mailto:nma at]
To: mathgroup at

I think of a the Head of expression as its 'type'.

One is supposed to be able to use Apply[f,expr] to change head of expression
to f.

But Why can't I use this to change the head of a Real number to Integer?

x = 0.1
        ------------------->Real. I was expecting Intger
x = Integer[x]
      ----------------> Now it says Integer

any idea?

ofcourse the question as to what should happen to the value of the variable
if for example I change the head of 0.5 from Real to Integer is another
matter. It seems in this case x remained 0.1 but only the head said Integer


Now sure what the above really means :)


  • Prev by Date: Re: fast replace for matrix minor
  • Next by Date: Re: Re: init.m of FrontEnd in M5.2
  • Previous by thread: Re: question on changing 'type' of numbers
  • Next by thread: Re: RE: question on changing 'type' of numbers