Skip to content

2.03 Extract a column or row

Boris Shilov edited this page Jun 21, 2019 · 3 revisions

Extract a column

A CollSeqN is also a ProductN (essentially a tuple). To extract a column:

import com.github.marklister.collections._
CollSeq(("A",2,3.1),
        ("B",3,4.0),
        ("C",4,5.2))._1

res1: Seq[String] = List(A, B, C)

Repeatedly extracting the same column will return a cached copy of the same Seq.

Extract a row

CollSeq is an IndexedSeq so you can extract a row in the normal manner:

import com.github.marklister.collections._
CollSeq(("A",2,3.1),
        ("B",3,4.0),
        ("C",4,5.2)) (1)

res4: Product3[java.lang.String,Int,Int] = (B,3,4)