Skip to content

Instantly share code, notes, and snippets.

@ChrisWhealy
Created April 29, 2016 17:09
Show Gist options
  • Save ChrisWhealy/efa1fb1a25d7962ef1ffe720255d9a25 to your computer and use it in GitHub Desktop.
Save ChrisWhealy/efa1fb1a25d7962ef1ffe720255d9a25 to your computer and use it in GitHub Desktop.
Mindshift: Part 19, sample 7
var IS_MAGNITUDE_LTE =
qtyFn1 =>
qtyFn2 =>
IS_ZERO_MAGNITUDE(SUBTRACT_MAGNITUDES(qtyFn1)(qtyFn2));
var do_div_magnitudes =
div_next =>
count =>
pair =>
// Inner function
(remainder => divisor =>
IS_MAGNITUDE_LTE(divisor)(remainder)
(fn =>
(div_next(SUCC_MAGNITUDE(count))
(PAIR(SUBTRACT_MAGNITUDES(remainder)
(divisor))
(divisor)))
(fn))
(PAIR(count)(remainder)))
// Supply parameters to inner function
(HEAD(pair))
(TAIL(pair));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment