From 3d498c134a9c0ab61c86a233edd0b2eb76ef44eb Mon Sep 17 00:00:00 2001 From: stuebinm Date: Tue, 20 Jul 2021 20:43:16 +0200 Subject: playing around with IO in Nix --- nix-turing/io-example.nix | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 nix-turing/io-example.nix (limited to 'nix-turing/io-example.nix') 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 {}.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!")) +] -- cgit v1.2.3