언어/Scala
원소 숫자 세기 : count number of elements
nanon
2020. 1. 24. 23:05
리스트의 원소 숫자 세기 : counting number of elements in the list
ex. ["a", "b", "c" ,"a", "c", "a" ] -> [("a", 3), ("b",1), ("c", 2)]
def count(L : list) = L.groupby(identity).mapValues(_.size)