Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function pair(a, b) {
- return function (selector) {
- if (selector) {
- return a;
- }
- return b;
- }
- }
- function first(p) {
- if (p) {
- return p(true);
- }
- }
- function remaining(p) {
- if (p) {
- return p(false);
- }
- }
- function enqueue(element, p) {
- return pair(element, p);
- }
- function get(nth, q) {
- if (nth === 0) {
- return first(q);
- }
- return get(nth - 1, remaining(q));
- }
- console.log(get(2, enqueue(3, enqueue(2, enqueue(1)))));
Add Comment
Please, Sign In to add comment