Matrix multiplication: Difference between revisions

Content added Content deleted
mNo edit summary
Line 1,429: Line 1,429:
=={{header|Elixir}}==
=={{header|Elixir}}==
<lang elixir>
<lang elixir>
def mult(m1, m2) do
Enum.map m1, fn (x) -> Enum.map t(m2), fn (y) -> Enum.zip(x, y)
|> Enum.map(fn {x, y} -> x * y end)
|> Enum.reduce(0, &+/2)
end
end
end

def t(m) do # transpose
List.zip(m) |> Enum.map(&Tuple.to_list(&1))
end



</lang>
</lang>