diff options
Diffstat (limited to '')
-rw-r--r-- | nix-turing/io-example.nix | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/nix-turing/io-example.nix b/nix-turing/io-example.nix new file mode 100644 index 0000000..9692629 --- /dev/null +++ b/nix-turing/io-example.nix @@ -0,0 +1,41 @@ +with import <nixpkgs> {}.lib; + +let + # all possible winning rows + winning = [ + ["tl" "tm" "tr"] + ["ml" "mm" "mr"] + ["bl" "bm" "br"] + ["tl" "ml" "bl"] + ["tm" "mm" "bm"] + ["tr" "mr" "br"] + ["tl" "mm" "br"] + ["bl" "mm" "tr"] + ]; + + showGrid = grid: with grid; '' + ===========GRID=========== + ${tl} | ${tm} | ${tr} + --------- + ${ml} | ${mm} | ${mr} + --------- + ${bl} | ${bm} | ${br} + ''; + + # the inital empty grid + emptyGrid = listToAttrs + (map (name: {inherit name; value = " ";}) + ["tl" "tm" "tr" "ml" "mm" "mr" "bl" "bm" "br"]); + +in {seed}: +with import ./io.nix {s = seed;}; + +do initialWorld [ + (v: read_input "hello!") + (log) + (v: read_input "lalala second round!") + (log) + (ifThenElse (v: v == "condition\n") + (v: log "condition was met!") + (v: log "condition did not hold!")) +] |