Use unflatten method from P9 and filter it before mapping the sublist as a tuple:
println(ulist.filter(_.length > 1).map(e=>(e.length,e.head)))
List((6,'a), (2,'c), (4,'e))
- P12: Decode run-length encoding
- P11: Modified run-length encoding that includes on...
- Installing Eclipse, Scala and Groovy in Windows 7
- P10: Run-length encoding of a list.
- P09: Pack consecutive duplicates of list elements...
- P08: Eliminate consecutive duplicates of list elem...
- P07: Flatten a list
- P06: Is a list palindrome
- P03 - P05: Find nth element, length, reverse a lis...
- How to simply sum values in a Map in Scala
- Best Note Taking Tools
- P02: Find the last but one element of a list.
- Over all these years of Software development, I ca...
- ▼ October (13)