davv: The bluegreen quadruped. (Default)
Dw ([personal profile] davv) wrote2014-01-23 05:27 pm

Also,

recursion is fun! It feels more like magic.

Here's a nice functional programming exercise I did today: Given a function that increments an integer and a function that decrements it, create a function that returns the sum of two numbers, where either of the two numbers may be positive or negative.
lhexa: (literate)

[personal profile] lhexa 2014-01-23 04:57 pm (UTC)(link)
Weirldy enough, that's also how it's done in a fair chunk of mathematical logic, such as Peano arithmetic. I guess it's because you need fewer axioms, if your only operation is "add one".

lhexa: (literate)

[personal profile] lhexa 2014-01-24 01:56 am (UTC)(link)
Yeah, it's just the natural numbers.