# transpose

## definition

The transpose method will pair and overlay elements from another collections into a single collection.

可以理解为矩阵转置

```scala
def transpose[B](implicit asTraversable: (A) ⇒ GenTraversableOnce[B]): CC[CC[B]]
```

## demo

```scala
scala> val donuts: Seq[String] = Seq("Plain Donut", "Strawberry Donut", "Glazed Donut")
donuts: Seq[String] = List(Plain Donut, Strawberry Donut, Glazed Donut)

scala> val prices: Seq[Double] = Seq(1.50, 2.0, 2.50)
prices: Seq[Double] = List(1.5, 2.0, 2.5)

scala> val donutList = List(donuts, prices)
donutList: List[Seq[Any]] = List(List(Plain Donut, Strawberry Donut, Glazed Donut), List(1.5, 2.0, 2.5))

scala> donutList.transpose
res7: List[List[Any]] = List(List(Plain Donut, 1.5), List(Strawberry Donut, 2.0), List(Glazed Donut, 2.5))
```

## demo2

```scala
scala> val donuts: Seq[String] = Seq("Plain Donut", "Strawberry Donut", "Glazed Donut")
donuts: Seq[String] = List(Plain Donut, Strawberry Donut, Glazed Donut)

scala> val prices: Seq[Double] = Seq(1.50, 2.0, 2.50)
prices: Seq[Double] = List(1.5, 2.0, 2.5)

scala> val colors: Seq[String] = Seq("Green", "Blue", "Red")
color: Seq[String] = List(Green, Blue, Red)

scala> val donutList = List(donuts, prices, colors)
donutList: List[Seq[Any]] = List(List(Plain Donut, Strawberry Donut, Glazed Donut), List(1.5, 2.0, 2.5), List(Green, Blue, Red))

scala> donutList.transpose
res8: List[List[Any]] = List(List(Plain Donut, 1.5, Green), List(Strawberry Donut, 2.0, Blue), List(Glazed Donut, 2.5, Red))
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.selinux.tech/scala/function-operation/t/transpose.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
