从每个列表将包含另一个列表集合中x位置的元素的位置获取列表 [英] Get lists from where each list will contain the elements from a x position from another collection of lists

查看:106
本文介绍了从每个列表将包含另一个列表集合中x位置的元素的位置获取列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上有这个:

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

我想得到这个(垂直阅读/旋转90度):

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

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

有人知道在f#中执行此操作的简单方法吗?

anybody knows an easy way of doing this in f# ?

推荐答案

我可以通过转换为数组来实现-

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])

这篇关于从每个列表将包含另一个列表集合中x位置的元素的位置获取列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆