Re: OT Why Am I doing this?
- From: Kent M Pitman <pitman@xxxxxxxxxxx>
- Date: 24 Oct 2007 20:44:18 -0400
Ken Tilton <kennytilton@xxxxxxxxxxxxx> writes:
My Algebra model sees the world as either unary or binary, so 1+2+3
cannot be (+ 1 2 3). Instead, I follow the associative thing and
encode the infix as (+ (+ 1 2) 3).
Can anyone tell me why I am encoding --42 as (- (- 42)) instead of (-
(-
42)?
- and + are overloaded, not generic.
(- x)
is not the degenerate case of
(- x y)
In fact, it's not even shorthand for
(- 0 x)
because of the issue that
(- 0.0)
must return -0.0, not 0.0 (if a representation for -0.0 is available).
Consequently, the reason you encode --42 as (- (- 42)) is the same reason
you encode f(f(x)) as (f (f x)).
Extra credit: which do you think is mathematically more honest?
--x is mathematically more honest as (- (- x)).
Now whether --3 is better as (- -3) or (- (- 3)), and whether -3 is better
as (- 3) or -3, that's harder to say.
I'll try googling sign+associative
I'll just note that your choice of search keyword biases the answer.
Why not google for minus+overloaded or
mathematicians+of+yesteryear+weren%27t+programmers and see if the
answer is the same. The virtue of traditional math notation isn't
that it's good, it's that it's widely taught.
.
- References:
- OT Why Am I doing this?
- From: Ken Tilton
- OT Why Am I doing this?
- Prev by Date: Re: Why "Let*" and not "Let" after "do" in a loop??? Grrr.
- Next by Date: Re: Common Lisp and RegressionTesting
- Previous by thread: Re: OT Why Am I doing this?
- Next by thread: Re: OT Why Am I doing this?
- Index(es):