Is there a transpose function in Elixir?

前端 未结 3 932
鱼传尺愫
鱼传尺愫 2020-12-19 01:03

Hi I look for a transpose function in Elixir. For example I have this kind of array a and after calling a function the result should be b:

3条回答
  •  余生分开走
    2020-12-19 01:38

    There (still) isn't one in Elixir, but you can use:

    def transpose(rows) do
      rows
      |> List.zip
      |> Enum.map(&Tuple.to_list/1)
    end
    

提交回复
热议问题