Skip to content

Instantly share code, notes, and snippets.

@dland
Created October 18, 2015 20:47
Show Gist options
  • Save dland/69e656e8fabc93187bee to your computer and use it in GitHub Desktop.
Save dland/69e656e8fabc93187bee to your computer and use it in GitHub Desktop.
Elixir playground, pt 1
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