language: introduce the requirement to use return to return a value from a function

This commit is contained in:
2023-11-21 04:28:46 -08:00
parent 5540918e7c
commit 0a2d029c5c
27 changed files with 115 additions and 19 deletions

View File

@ -56,15 +56,15 @@ func drawCells(renderer, cells, swap) {
func createCellGrid() {
let numCells = gridWidth * gridHeight
listInitWith(numCells, 0)
return listInitWith(numCells, 0)
}
func getCell(cells, swap, x, y) {
if (x >= 0) and (y >= 0) and (x < gridWidth) and (y < gridHeight) {
let mask = if swap { 2 } else { 1 }
(cells[x + y * gridWidth] & mask) != 0
return (cells[x + y * gridWidth] & mask) != 0
} else {
false
return false
}
}
@ -88,7 +88,7 @@ func countNeighbours(cells, swap, x, y) {
if getCell(cells, swap, x - 1, y + 1) { count++ }
if getCell(cells, swap, x - 1, y) { count++ }
if getCell(cells, swap, x - 1, y - 1) { count++ }
count
return count
}
func gameOfLife(cells, swap) {