-module(diag).
-export([sweep/2]).
sweep(Width, Height) ->
sweep(Width, Height, 0, Width + Height - 1).
sweep(Width, Height, N, N) ->
print(Width, Height, N);
sweep(Width, Height, N, Max) ->
print(Width, Height, N),
sweep(Width, Height, N + 1, Max).
print(Width, Height, N) ->
iterate(fun(X) ->
case X > Width of
true ->
repeat(fun() -> io:format("1 ") end, Width);
false ->
repeat(fun() -> io:format("1 ") end, X),
repeat(fun() -> io:format("0 ") end, Width - X)
end,
io:format("\n"),
case X =:= 0 of
true ->
0;
false ->
X - 1
end
end, N, Height),
io:format("\n").
iterate(_Fun, Input, 0) ->
Input;
iterate(Fun, Input, N) ->
iterate(Fun, Fun(Input), N - 1).
repeat(_Fun, 0) ->
ok;
repeat(Fun, N) ->
Fun(),
repeat(Fun, N - 1).
Attached: file.png (307x1000, 193K)