Created
February 29, 2016 12:27
-
-
Save ties/2436f6e1778b6111e658 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
| freeDimensions(data, usedKeys) { | |
| // list[][map] | |
| const usedKeySet = Set(usedKeys) | |
| // Take the entries of which the key has not been seen | |
| const unusedEntries = data.flatMap(v => v.entrySeq().filter(kv => !usedKeySet.contains(kv[0]))) | |
| // Group these entries by key, then create a set of their values | |
| const unusedMap = unusedEntries.groupBy(kv => kv[0]).map(v => Set(v.map(kv => kv[1]))) | |
| // Return the elements with more than one entry | |
| return unusedMap.filter(v => v.count() > 1) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment