Last active
April 12, 2022 15:12
-
-
Save adrian154/c85fa521d6eff972a8042fc23820b06e to your computer and use it in GitHub Desktop.
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
| const pass = (fn, value) => { | |
| fn(value); | |
| return value; | |
| }; | |
| const UP = (point, fn) => pass(fn, [point[0], point[1] + 1]), | |
| DOWN = (point, fn) => pass(fn, [point[0], point[1] - 1]), | |
| LEFT = (point, fn) => pass(fn, [point[0] - 1, point[1]]), | |
| RIGHT = (point, fn) => pass(fn, [point[0] + 1, point[1]]); | |
| const A = (p, fn, n) => n == 0 ? p : | |
| B(DOWN(A(RIGHT(A(UP(D(p, fn, n - 1), fn), fn, n - 1), fn), fn, n - 1), fn), fn, n - 1); | |
| const B = (p, fn, n) => n == 0 ? p : | |
| A(RIGHT(B(DOWN(B(LEFT(C(p, fn, n - 1), fn), fn, n - 1), fn), fn, n - 1), fn), fn, n - 1); | |
| const C = (p, fn, n) => n == 0 ? p : | |
| D(UP(C(LEFT(C(DOWN(B(p, fn, n - 1), fn), fn, n - 1), fn), fn, n - 1), fn), fn, n - 1); | |
| const D = (p, fn, n) => n == 0 ? p : | |
| C(LEFT(D(UP(D(RIGHT(A(p, fn, n - 1), fn), fn, n - 1), fn), fn, n - 1), fn), fn, n - 1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment