Skip to content

Instantly share code, notes, and snippets.

@mxmerz
Forked from J12D/gist:4132661
Created November 22, 2012 20:03
Show Gist options
  • Save mxmerz/4132729 to your computer and use it in GitHub Desktop.
Save mxmerz/4132729 to your computer and use it in GitHub Desktop.
Forloop
forloop(0) ->
bin_fertig;
forloop(i) ->
weiter_gehts,
forloop(i-1).
makePic(Height, Width, Function) ->
loop(Height, Width, Width, Function, [], []).
%% loop(current height, current width, width, function, line accumulator, accumulator)
loop(-1, Width, Width, Function, LineAcc, Acc) ->
Acc;
loop(H, -1, Width, Function, LineAcc, Acc) ->
loop(H-1, Width, Width, Function, [], [LineAcc|Acc]);
loop(H, W, Width, Function, LineAcc, Acc) ->
loop(H, W-1, Width, Function, [Function(H, W)|LineAcc], Acc).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment