Peano Arithmetic

Michael Haufe TNO at TheNewObjective.com
Fri Aug 15 21:41:40 PDT 2008


Maciej Stachowiak wrote:
>
> On Aug 15, 2008, at 9:17 PM, Michael Haufe wrote:
>
>>
>> --------------------------------------------------------------
>>
>> (define (+ x y)
>>    (if (= x 0)
>>        y
>>        (+ (-1+ x) (1+ y))))
>>
>> function add(x,y) (!x) ? y : add(--x,++y);
>> --------------------------------------------------------------
>> I don't claim to be a Scheme expert, but I believe my interpretation 
>> to be correct.
>> I am also aware of the recursion limits of ES having used it for a 
>> number of years.
>> This is for personal study and amusement.
>
> I do claim to be a Scheme expert, and I believe your interpretation is 
> incorrect. The -1+ and 1+ procedures in Scheme return a value derived 
> by adding either -1 or +1 to their argument, but do not mutate their 
> argument - a Scheme procedure cannot do so, only a special form could. 
> However, ECMAScript -- and ++ mutate the referenced location, in 
> addition to returning a value. Preincrement/predecrement operators 
> will at least return the modified instead of the original value, 
> unlike the post versions, but they are still mutators and thus do not 
> match the Scheme seantics.
>
> Regards,
> Maciej
>
>
>

Then I stand corrected, much appreciated.



More information about the Es-discuss mailing list