home
/
code
/
cellular-automata.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
6fe41dc
)
Replace for-loop with map.
author
Siraaj Khandkar
<siraaj@khandkar.net>
Tue, 9 Aug 2016 16:48:26 +0000
(12:48 -0400)
committer
Siraaj Khandkar
<siraaj@khandkar.net>
Tue, 9 Aug 2016 16:48:26 +0000
(12:48 -0400)
life/006/life.ts
patch
|
blob
|
blame
|
history
diff --git
a/life/006/life.ts
b/life/006/life.ts
index
ac4b969
..
7b6ad3b
100644
(file)
--- a/
life/006/life.ts
+++ b/
life/006/life.ts
@@
-53,15
+53,8
@@
class Grid<A> implements GridInterface<A> {
};
map(f : (location: GridLocation) => A) {
- const cells = [];
- for (let r = 0; r < this.rows; r++) {
- cells[r] = [];
- for (let k = 0; k < this.columns; k++) {
- const location = {r: r, k: k};
- cells[r][k] = f(location);
- }
- };
- this.cells = cells;
+ this.cells =
+ this.cells.map((row, r) => row.map((_, k) => f({r: r, k: k})));
};
private print_border(): void {
This page took
0.029049 seconds
and
4
git commands to generate.