Course of Raku / Addendum 🆕 / Working with data / Lists, arrays, and hashes / Exercises

Transpose a matrix

Problem

Treat the nested list [1, 2, 3], [4, 5, 6] as a 2×3 matrix and transpose it into a 3×2 matrix, so the rows become columns. Print the result.

Example

The program prints:

((1 4) (2 5) (3 6))

Solution

See the solution

Course navigation

Solution: Running totals   |   Solution: Transpose a matrix