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
// Given an array collection (may be a Swift Array or an Objective-C NSArray) | |
// and a function that optionally maps each element to its corresponding group, | |
// return a Swift Dictionary of the mapped elements in their groups. | |
// | |
// Usage: | |
// func keyFunc(o: V) -> K {...} | |
// let grouped = groupBy(keyFunc)([V]) | |
// | |
// Example: | |
// func length(s: String) -> Int { return countElements(s) } |