Last active
January 20, 2018 21:30
-
-
Save ahmedelgabri/0e1e94751aaec99a0afa35f6332431d2 to your computer and use it in GitHub Desktop.
This file contains 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
fmap = (f => g => x => (f (g (x)))) | |
curryOnce = (f => x => (...xs) => (f (x, ...xs))) | |
curry = (n => f => ( | |
(n === 1) ? | |
(f) : | |
(fmap (curry (n - 1)) (curryOnce (f))))) | |
method = (m => (m.call.bind (m))) | |
methodWithArgs = (n => m => (curry (n) (method (m)))) | |
flip = (f => x => y => (f (y) (x))) | |
split = (methodWithArgs (2) (''.split)) | |
map = (flip (methodWithArgs (2) ([].map))) | |
;;; | |
(console.log | |
(map (x => (x * 2)) | |
(split ('1 2 3 4 5') (' ')))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment