Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Nov 6th, 2012  |  syntax: Erlang  |  size: 0.29 KB  |  views: 47  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. -module(fix).
  2. -export([partition/2]).
  3.  
  4. partition(List, Size) ->
  5.     lists:reverse(partition(List, Size, 1, [])).
  6.  
  7. partition(List, _Size, Idx, Acc) when Idx > length(List) -> Acc;
  8. partition(List, Size, Idx, Acc) ->
  9.     partition(List, Size, Idx + Size, [lists:sublist(List, Idx, Size)|Acc]).