Scala list of list count different elements per sublist index -


I have a list of lists with the following data

val list = list ( List ("A", "A", "A"), List ("A", "B", "C"), List ("D", "E", "F"),

I want to understand that there are many different figures of each Spibs

1 - & gt; List ("a", "d", "a")

2 - & gt; List ("B", "E", "A")

3 - & gt; List ("C", "F", "A")

Is there any way to do this? It does not need to be indexed, but I'll copy the index requires different values, can be found

2 // different values ​​A and d

3 // Various values ​​B, E and A

3 // Various values ​​C, F and A

varies to remove duplicate :

  scala & gt; List.transpose.map (_Special.size) res0: list [int] = list (2, 3, 3)   

If all lists are not there then it will throw an exception It's the same size, but that's probably what you want.

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -