examples: update `[0;n]` to `[0].repeat(n)`
parent
854de4e7e0
commit
5f43a61e0d
|
@ -52,7 +52,7 @@ fn main() {
|
||||||
for {
|
for {
|
||||||
mut new_field := []array_int
|
mut new_field := []array_int
|
||||||
for i, line in field {
|
for i, line in field {
|
||||||
new_field << [0; line.len]
|
new_field << [0].repeat(line.len)
|
||||||
}
|
}
|
||||||
for i, line in field {
|
for i, line in field {
|
||||||
if i == 0 || i == field.len - 1{continue}
|
if i == 0 || i == field.len - 1{continue}
|
||||||
|
|
|
@ -39,7 +39,7 @@ fn (v mut []f64) times_trans(u []f64) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (v mut []f64) a_times_transp(u []f64) {
|
fn (v mut []f64) a_times_transp(u []f64) {
|
||||||
mut x := [f64(0); u.len]
|
mut x := [f64(0)].repeat(u.len)
|
||||||
x.times(u)
|
x.times(u)
|
||||||
v.times_trans(x)
|
v.times_trans(x)
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,7 +167,7 @@ fn (g mut Game) init_game() {
|
||||||
g.field = []array_int // TODO: g.field = [][]int
|
g.field = []array_int // TODO: g.field = [][]int
|
||||||
// Generate the field, fill it with 0's, add -1's on each edge
|
// Generate the field, fill it with 0's, add -1's on each edge
|
||||||
for i := 0; i < FieldHeight + 2; i++ {
|
for i := 0; i < FieldHeight + 2; i++ {
|
||||||
mut row := [0; FieldWidth + 2]
|
mut row := [0].repeat(FieldWidth + 2)
|
||||||
row[0] = - 1
|
row[0] = - 1
|
||||||
row[FieldWidth + 1] = - 1
|
row[FieldWidth + 1] = - 1
|
||||||
g.field << row
|
g.field << row
|
||||||
|
|
Loading…
Reference in New Issue