home
/
code
/
cellular-automata.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Reformatting for consistency.
[cellular-automata.git]
/
003
/
src
/
life.erl
diff --git
a/003/src/life.erl
b/003/src/life.erl
index
f8b6bcc
..
5f91d26
100644
(file)
--- a/
003/src/life.erl
+++ b/
003/src/life.erl
@@
-12,10
+12,10
@@
-record(state, {x :: non_neg_integer()
,y :: non_neg_integer()
-record(state, {x :: non_neg_integer()
,y :: non_neg_integer()
- ,n ::
non_neg
_integer()
- ,bar :: string()
+ ,n ::
pos
_integer()
+ ,bar ::
nonempty_
string()
,board :: array()
,board :: array()
- ,gen_count ::
non_neg
_integer()
+ ,gen_count ::
pos
_integer()
,gen_duration :: non_neg_integer()
,print_time :: non_neg_integer()
}).
,gen_duration :: non_neg_integer()
,print_time :: non_neg_integer()
}).
@@
-61,7
+61,12
@@
life_loop(
end
),
end
),
- {NewTime, NewBoard} = timer:tc(fun() -> next_generation(X, Y, Board) end),
+ {NewTime, NewBoard} = timer:tc(
+ fun() ->
+ next_generation(X, Y, Board)
+ end
+ ),
+
NewState = State#state{board = NewBoard
,gen_count = GenCount + 1
,gen_duration = NewTime
NewState = State#state{board = NewBoard
,gen_count = GenCount + 1
,gen_duration = NewTime
@@
-89,7
+94,7
@@
do_print_status(Bar, X, Y, N, GenCount, TimeMic, PrintTimeMic) ->
do_print_board(Board) ->
do_print_board(Board) ->
-
CharList
s = array:to_list(
+
RowString
s = array:to_list(
array:map(
fun(_, Row) ->
array:to_list(
array:map(
fun(_, Row) ->
array:to_list(
@@
-106,10
+111,10
@@
do_print_board(Board) ->
),
ok = lists:foreach(
),
ok = lists:foreach(
- fun(
CharList
) ->
- ok = io:format("~s~n", [
CharList
])
+ fun(
RowString
) ->
+ ok = io:format("~s~n", [
RowString
])
end,
end,
-
CharList
s
+
RowString
s
).
).
This page took
0.029991 seconds
and
4
git commands to generate.