Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
18
Task/Matrix-transposition/Erlang/matrix-transposition.erl
Normal file
18
Task/Matrix-transposition/Erlang/matrix-transposition.erl
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
-module(transmatrix).
|
||||
-export([trans/1,transL/1]).
|
||||
|
||||
% using built-ins hd = head, tl = tail
|
||||
|
||||
trans([[]|_]) -> [];
|
||||
trans(M) ->
|
||||
[ lists:map(fun hd/1, M) | transpose( lists:map(fun tl/1, M) ) ].
|
||||
|
||||
% Purist version
|
||||
|
||||
transL( [ [Elem | Rest] | List] ) ->
|
||||
[ [Elem | [H || [H | _] <- List] ] |
|
||||
transL( [Rest |
|
||||
[ T || [_ | T] <- List ] ]
|
||||
) ];
|
||||
transL([ [] | List] ) -> transL(List);
|
||||
transL([]) -> [].
|
||||
Loading…
Add table
Add a link
Reference in a new issue