equal
deleted
inserted
replaced
|
1 def distinctBy[B, C](xs: List[B], f: B => C, acc: List[C] = Nil): List[B] = xs match { |
|
2 case Nil => Nil |
|
3 case (x::xs) => { |
|
4 val res = f(x) |
|
5 if (acc.contains(res)) distinctBy(xs, f, acc) |
|
6 else x::distinctBy(xs, f, res::acc) |
|
7 } |
|
8 } |
|
9 |
|
10 |
|
11 |