Skip to content

Instantly share code, notes, and snippets.

@ysmood
Created January 17, 2019 09:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ysmood/ed1d6e7f29e8e6ddf02b0d790bb83227 to your computer and use it in GitHub Desktop.
Save ysmood/ed1d6e7f29e8e6ddf02b0d790bb83227 to your computer and use it in GitHub Desktop.
let inc = n => ++n
let dec = n => --n
function add (x, y) {
if (y < 0) return add(dec(x), inc(y))
if (y === 0) return x
if (y > 0) return add(inc(x), dec(y))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment