Skip to content

Instantly share code, notes, and snippets.

View jpidelatorre's full-sized avatar
🤖

Juan Pablo de la Torre jpidelatorre

🤖
View GitHub Profile
@jpidelatorre
jpidelatorre / LICENSE.md
Last active October 17, 2018 22:47
Pub/Sub golf edition

DON'T BLAME ME LICENSE

v0 Jun 2018

You are allowed to use, modify or distribute this piece of code as pleased. The author cannot be made responsible for anything that could derive from the use or misuse of this software.

@jpidelatorre
jpidelatorre / fractions.annotated.js
Last active September 13, 2018 00:36
Returns an equivalent fraction to a number larger than 0 (limited by a rather limited call stack size cap)
f = ( // Given
n, // A number greater than 0 (limited by the call stack size cap)
a, // An optional numerator
b // And an optional denominator
) =>
[ // Have a collection of functions that
_ => f(n, a + 1, b), // - Adds one to the numerator if the fraction is smaller than the number
_ => `${a}/${b}`, // - Returns a string of the resulting fraction if it's equal to the number
_ => f(n, a, b + 1), // - Adds one to the denominator if the fraction is larger than the number
][ // And return the value of one based on