Author | Message |
---|---|
rabbott
Posts: 1649
|
Posted 20:55 Oct 30, 2012 |
A number of people used groupBy in solving some of the problems this week. That was quite appropriate. But when I asked how groupBy worked, very few could explain it. Here's an example.
val oneToTen = 1 to 10
oneToTen.groupBy( x => x % 3)
Run it and see what happens. Can you explain how groupBy works? By explain, I mean can you tell me the step-by-step process groupBy goes through to get from its starting point to the result it produces. Ask yourself what sort of data structure does groupBy produce? How does it determine what the keys are? How does it determine what the values are for those keys?
Last edited by rabbott at
09:49 Nov 01, 2012.
|