Created
October 18, 2015 20:47
-
-
Save dland/69e656e8fabc93187bee to your computer and use it in GitHub Desktop.
Elixir playground, pt 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Given the module: | |
import Enum | |
defmodule D do | |
def transpose(t) do | |
map(0..count(at(t, 0))-1, fn(x) -> map(t, fn(y) -> at(y, x) end) end) | |
end | |
end | |
This produces | |
iex(7)> m=[[1,2],[3,4]] | |
[[1, 2], [3, 4]] | |
iex(8)> transpose(m) | |
[[1, 3], [2, 4]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment