Skip to content

Instantly share code, notes, and snippets.

@ties
Created February 29, 2016 12:27
Show Gist options
  • Save ties/2436f6e1778b6111e658 to your computer and use it in GitHub Desktop.
Save ties/2436f6e1778b6111e658 to your computer and use it in GitHub Desktop.
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