Skip to content
Snippets Groups Projects
Commit cc690fa5 authored by Matt Bovel's avatar Matt Bovel
Browse files

Rename result to acc

parent 184c0480
No related branches found
No related tags found
No related merge requests found
......@@ -4,13 +4,13 @@
```scala
def groupBy[T, S](f: T => S)(xs: List[T]): Map[S, List[T]] =
var result = Map[S, List[T]]()
var acc = Map[S, List[T]]()
xs.reverse.foreach(el =>
val key = f(el)
val prevValue = result.getOrElse(key, List())
result = result.updated(key, el :: prevValue)
val prevValue = acc.getOrElse(key, List())
acc = acc.updated(key, el :: prevValue)
)
result
acc
```
```scala
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment