Not super-short:
List(1,2,3,4).grouped(2).collect{ case List(k,v) => k -> v }.toMap
More Related Contents:
- Combining two lists into one in Scala
- Cleaner way to update nested structures
- Why is Scala’s immutable Set not covariant in its type?
- Spark Scala: How to convert Dataframe[vector] to DataFrame[f1:Double, …, fn: Double)]
- How can I change column types in Spark SQL’s DataFrame?
- How to override apply in a case class companion
- Need clarification on Scala literal identifiers (backticks)
- Scala how can I count the number of occurrences in a list
- Case class to map in Scala
- Spark losing println() on stdout
- Spark DataFrame: does groupBy after orderBy maintain that order?
- Spark UDAF with ArrayType as bufferSchema performance issues
- When to use the equals sign in a Scala method declaration?
- “new” keyword in Scala
- Spark: produce RDD[(X, X)] of all possible combinations from RDD[X]
- Functional programming, Scala map and fold left [closed]
- What does => and () => mean in Scala [duplicate]
- Load Scala file into interpreter to use functions?
- Scala underscore minimal function
- Any reason why scala does not explicitly support dependent types?
- Reduce, fold or scan (Left/Right)?
- Scala case class inheritance
- Apache Spark, add an “CASE WHEN … ELSE …” calculated column to an existing DataFrame
- Scala: pass Seq to var-args functions
- Can’t prove that singleton types are singleton types while generating type class instance
- Clarification needed about futures and promises in Scala
- Why does Scala support shadow variables? [closed]
- How to sort an RDD in Scala Spark?
- Insert if not exists in Slick 3.0.0
- Difference between two rows in Spark dataframe