Last active
August 29, 2015 14:22
-
-
Save lexfrl/8cab30c7983e2893caed 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
| static getMapPaths(map) { | |
| map = new Map(map); | |
| getPaths = (map, result = new List([])) => { | |
| if (!Map.isMap(map)) { | |
| return result; | |
| } | |
| return map.flip().toList().reduce((res, k) => { | |
| return res.push(getPaths((map.get(k)), result.push(k))); | |
| }, new List()); | |
| }; | |
| return getPaths(map).flatten(1); | |
| } | |
| static getMapPaths(map) { | |
| map = new Map(map); | |
| getPaths = (map, result = new List([])) => ( | |
| !Map.isMap(map) && result || | |
| map.flip().toList().reduce( | |
| (res, k) => res.push(getPaths((map.get(k)), result.push(k))), | |
| new List())); | |
| return getPaths(map).flatten(1); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment