Guest User

Untitled

a guest
Oct 18th, 2017
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. -module(khf1).
  2. -author('najibg96@gmail.com').
  3. -vsn('2017-10-17').
  4. -export([cella/2]).
  5.  
  6. cella(S, I) ->
  7. M = length(S),
  8. K = trunc(math:sqrt(M)),
  9. IS = (((I-1) div K) * K) + 1,
  10. JS = (((I-1) rem K) * K) + 1,
  11. SL = lists:sublist(S, IS, K),
  12. lists:flatten(transpose([lists:sublist(L, JS, K) || L <- SL])).
  13.  
  14. transpose([[]|_]) -> [];
  15. transpose(M) ->
  16. [lists:map(fun hd/1, M) | transpose(lists:map(fun tl/1, M))].
Add Comment
Please, Sign In to add comment