scala - Filter matching and non-matching elements into different halves of a tuple -


is there simple , efficient way perform following in scala?

val elements = list(1, 2, 3, 4, 5, 6) val (odd, even) = elements.filter(_ % 2 == 0) 

i aware of groupby, works constant number of groups can extracted separate values.

list.partition want:

val (even, odd) = elements.partition(_ % 2 == 0) 

note works 2 final groups.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -