Last active
March 19, 2018 06:01
-
-
Save JustinSDK/1bafd8382621854cbc72e80b02a7b050 to your computer and use it in GitHub Desktop.
console.log([1, 2, 3].map(elem => elem - 1))?(part 2)
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
| function array(lt) { | |
| let yes = f => y => f(); | |
| let no = x => f => f(); | |
| let when = c => c; | |
| let undef = (_ => _)(); | |
| let is_undef = n => n === undef ? yes : no; | |
| let pair = l => r => f => f(l)(r); | |
| let left = p => p(l => _ => l); | |
| let right = p => p(_ => r => r); | |
| let nil = pair(undef)(undef); | |
| let con = h => t => pair(h)(t); | |
| let head = left; | |
| let tail = right; | |
| let isEmpty = l => is_undef(head(l)); | |
| function arr(acc, l) { | |
| if(isEmpty(l) === yes) { | |
| return acc; | |
| } else { | |
| return arr(acc.concat([head(l)]), tail(l)); | |
| } | |
| } | |
| return arr([], lt); | |
| } | |
| let lt = (f => (x => f(n => x(x)(n)))(x => f(n => x(x)(n))))(map => l => f => (l => (n => n === (_ => _)() ? (f => y => f()) : (x => f => f()))((p => p(l => _ => l))(l)))(l)(() => ((l => r => f => f(l)(r))((_ => _)())((_ => _)())))(() => (h => t => (l => r => f => f(l)(r))(h)(t))(f((p => p(l => _ => l))(l)))(map((p => p(_ => r => r))(l))(f))))((es => (l => ((f => (x => f(n => x(x)(n)))(x => f(n => x(x)(n))))(rev => r => l => (l => (n => n === (_ => _)() ? (f => y => f()) : (x => f => f()))((p => p(l => _ => l))(l)))(l)(() => r)(() => rev((h => t => (l => r => f => f(l)(r))(h)(t))((p => p(l => _ => l))(l))(r))((p => p(_ => r => r))(l)))))((l => r => f => f(l)(r))((_ => _)())((_ => _)()))(l))(es()))((f => (x => f(n => x(x)(n)))(x => f(n => x(x)(n))))(rcon => t => h => (n => n === (_ => _)() ? (f => y => f()) : (x => f => f()))(h)(() => t)(() => rcon((h => t => (l => r => f => f(l)(r))(h)(t))(h)(t))))((l => r => f => f(l)(r))((_ => _)())((_ => _)()))(1)(2)(3)))(elem => elem - 1); | |
| console.log(array(lt)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment