scala - Remove unique items from sequence -


this question has answer here:

i find lot how remove duplicates, elegant way remove unique items first , remaining duplicates.

e.g. sequence (1, 2, 5, 2, 3, 4, 4, 0, 2) should converted (2, 4).

i can think of using for-loop add count each distinct item, imagine scala has more elegant way achieve this.

also keep in mind i => i can replaced identity , map(_._1) keys, this:

seq(1, 2, 5, 2, 3, 4, 4, 0, 2).groupby(identity).filter(_._2.size > 1).keys.toseq 

this countbykey method, such 1 can found in spark's api, useful.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -