3 ms·
you can notice a difference if you think about strict vs non-strict evaluation. the first implementation can be more efficient for implementing isPositive
by nh23423fefe 1y ago
you 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