Re: RE: question on changing 'type' of numbers
- To: mathgroup at smc.vnet.net
- Subject: [mg69550] Re: [mg69495] RE: [mg69473] question on changing 'type' of numbers
- From: Sseziwa Mukasa <mukasa at jeol.com>
- Date: Fri, 15 Sep 2006 06:45:36 -0400 (EDT)
- References: <200609141055.GAA21466@smc.vnet.net>
On Sep 14, 2006, at 6:55 AM, David Park wrote:
> However, there seem to be cases where this is only partly true. For
> example
> with complex numbers...
>
> AtomQ[2 + 3 I]
> True
>
> We can't change the Head
>
> Head[List @@ (2 + 3 I)]
> Complex
>
> 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.
I think this is a side effect of how different atoms are
represented. FullForm[9] is 9 but FullForm[9+I] is Complex[9,1], so
the pattern Complex[a_,b_] will match a complex number but Integer
[x_] will not match an integer. I'm too lazy to search for atoms
whose FullForm contains a pattern that I can match to, but that would
be the strategy for finding 'in between' objects.
Incidentally though there's no fundamental difference between
2 + I 3 /. Complex[a_, b_] -> {a, b}
and
9/.x_->{x,x}
the head isn't actually changing in either case.
Regards,
Ssezi
- References:
- RE: question on changing 'type' of numbers
- From: "David Park" <djmp@earthlink.net>
- RE: question on changing 'type' of numbers