Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -module(khf1).
- -author('najibg96@gmail.com').
- -vsn('2017-10-17').
- -export([cella/2]).
- cella(S, I) ->
- M = length(S),
- K = trunc(math:sqrt(M)),
- IS = (((I-1) div K) * K) + 1,
- JS = (((I-1) rem K) * K) + 1,
- SL = lists:sublist(S, IS, K),
- lists:flatten(transpose([lists:sublist(L, JS, K) || L <- SL])).
- transpose([[]|_]) -> [];
- transpose(M) ->
- [lists:map(fun hd/1, M) | transpose(lists:map(fun tl/1, M))].
Add Comment
Please, Sign In to add comment