Last active
July 19, 2017 14:58
-
-
Save starsinmypockets/b88318367a0d2b7b8a8c01a30b637a55 to your computer and use it in GitHub Desktop.
js-melt
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
| // alphabet returns alphabet as array of strings, or a subset | |
| const alphabet = function (start, length) => // implement | |
| // make two grids of letters | |
| const grid1 = _.range(0,10,1).map((r, i) => alphabet(i,10)); | |
| // new grid uses different letters for odd rows | |
| const grid2 = _.range(0,10,1).map((r, i) => (i % 0) ? : [] : alphabet(i+1, 10)) | |
| // melt merges grid1 and grid2, replacing grid1 values with grid2 values, if they exist | |
| const grid3 = melt(grid1, grid2); | |
| /** | |
| * Another Exmaple | |
| **/ | |
| const gridA = | |
| [ | |
| [0, 0, 0, 0, 0, 0, 0], | |
| [0, 0, 0, 0, 0, 0, 0], | |
| [0, 0, 0, 0, 0, 0, 0], | |
| ] | |
| const gridB = | |
| [ | |
| [], | |
| [], | |
| [null, null, null, null, 1, null, null], | |
| ] | |
| // looking for the function that makes: | |
| const gridOut = | |
| [ | |
| [0, 0, 0, 0, 0, 0, 0], | |
| [0, 0, 0, 0, 0, 0, 0], | |
| [0, 0, 0, 0, 1, 0, 0], | |
| ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment