Created
January 14, 2019 16:27
-
-
Save pete-murphy/581f7f5c416e4f27effeafe93a6cd925 to your computer and use it in GitHub Desktop.
Curios (AKA stealing functions from Haskell)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This one is based off a Mark Seeman blog post. | |
// He gives examples in Haskell (using `sprintf` magic) | |
// The cool thing is that in JavaScript we have | |
// n-ary (AKA variadic) functions. So this works: | |
liftN(6, (...args) => args.join(""))( | |
["P", "p"], | |
["a", "4"], | |
["ssw"], | |
["o", "0"], | |
["rd"], | |
["", "!"] | |
) | |
// I think this returns the same thing: | |
map(xs => xs.join(""))( | |
sequence(Array.of, [ | |
["P", "p"], | |
["a", "4"], | |
["ssw"], | |
["o", "0"], | |
["rd"], | |
["", "!"] | |
]) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment