-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* More inputs * Update DoesNotCrashTests.cs * Update DoesNotCrashTests.cs * Update ConstraintSolver_Operations.cs * Rename * Update ConstraintSolver_Operations.cs * Crashfix * Update ConstraintSolver_Rules.cs * Update ConstraintSolver_Rules.cs * Update BoundNode.cs * Added missing error check * Update Binder_Statement.cs * More bugfix * Return expr crashfix
- Loading branch information
1 parent
cd77faa
commit cd2d135
Showing
16 changed files
with
348 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import System.Console; | ||
import System.Linq.Enumerable; | ||
|
||
val width = 80; | ||
val height = 40; | ||
|
||
func render(map: Array2D<bool>) { | ||
for (y in Range(0, height)) { | ||
for (x in Range(0, width)) { | ||
val cell = map[x, y]; | ||
Write(if (cell) "o" else " "); | ||
} | ||
WriteLine(); | ||
} | ||
} | ||
|
||
func in_bounds(x: int32, y: int32): bool = | ||
0 <= x < width | ||
and 0 <= y < height; | ||
|
||
func count_neighbors(x: int32, y: int32, map: Array2D<bool>): int32 { | ||
func count_cell(x: int32, y: int32, map: Array2D<bool>): int32 = | ||
if (in_bounds(x, y) and map[x, y]) 1 | ||
else 0; | ||
|
||
var n = 0; | ||
n += count_cell(x - 1, y - 1, map); | ||
n += count_cell(x - 1, y, map); | ||
n += count_cell(x - 1, y + 1, map); | ||
n += count_cell(x, y - 1, map); | ||
n += count_cell(x, y + 1, map); | ||
n += count_cell(x + 1, y - 1, map); | ||
n += count_cell(x + 1, y, map); | ||
n += count_cell(x + 1, y + 1, map); | ||
return n; | ||
} | ||
|
||
func tick(front: Array2D<bool>, back: Array2D<bool>) { | ||
for (y in Range(0, height)) { | ||
for (x in Range(0, width)) { | ||
// Any live cell with two or three live neighbours survives. | ||
// Any dead cell with three live neighbours becomes a live cell. | ||
// All other live cells die in the next generation. Similarly, all other dead cells stay dead. | ||
val neighbors = count_neighbors(x, y, front); | ||
back[x, y] = | ||
if (front[x, y]) 2 <= neighbors <= 3 | ||
else if (neighbors == 3) true | ||
else false; | ||
} | ||
WriteLine(); | ||
} | ||
} | ||
|
||
public func main() { | ||
var front = Array2D(width, height); | ||
var back = Array2D(width, height); | ||
|
||
// Glider | ||
front[3, 3] = true; | ||
front[4, 4] = true; | ||
front[4, 5] = true; | ||
front[3, 5] = true; | ||
front[2, 5] = true; | ||
|
||
while (true) { | ||
tick(front, back); | ||
|
||
Clear(); | ||
render(front); | ||
|
||
// Swap | ||
val temp = front; | ||
front = back; | ||
back = temp; | ||
|
||
System.Threading.Thread.Sleep(200); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import System.Collections.Generic; | ||
import System.Linq.Enumerable; | ||
import System.Console; | ||
|
||
func main() { | ||
val l = List(); | ||
for (i in Range(0, 100)) { | ||
l.Add(i); | ||
} | ||
WriteLine("Count = \{l.Count}"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import System.Console; | ||
|
||
func arrayOf<T>(...vs: Array<T>): Array<T> = vs; | ||
|
||
func main() { | ||
for (s in arrayOf("abc", "def", "ghi")) { | ||
WriteLine(s); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.