3 ms·
Is there any notable difference between how it's presented in the post > Thus, addition is a function P:NxN -> N such that for all numbers a, b, > 1. P(a,0) =
by BoiledCabbage 1y ago
Is there any notable difference between how it's presented in the post
> Thus, addition is a function P:NxN -> N such that for all numbers a, b,
> 1. P(a,0) = a
> 2. P(a,S(b)) = S(P(a,b))
And this alternate formulation?
1. P(a,0) = a
2. P(a,S(b)) = P(S(a),b)
Ie "decrease one from b and add it to a", instead of "decrease one from b and add it to the total".
- nh23423fefe 1y agoyou can notice a difference if you think about strict vs non-strict evaluation. the first implementation can be more efficient for implementing isPositive isPositive x = case x when 0 = false when S _ = true then isPositive P(SSS0, SSSSS0) = isPositive S(P(SSS0, SSSS0)) and we can terminate right there the other formulation of plus is "strict" in the 2nd argument, you need to evaluate P |b| times to get a natural number out to case on, prior to that, you have a function call