Get lists from where each list will contain the elements from a x position from another collection of lists

前端 未结 2 783
太阳男子
太阳男子 2021-01-25 08:47

basically having this:

[
[1;2;3];
[4;5;7];
[8;9;0];
]

I would like to get this (read vertically/ turn 90 degrees):

[
[1;4;8];
[         


        
2条回答
  •  时光说笑
    2021-01-25 09:28

    I would do it by converting to arrays -

    let arr = input |> List.map (List.toArray) |> List.toArray //a array of arrays
    let out = Array2D.create size1 size2 (fun x y -> arr.[y].[x])
    

提交回复
热议问题