diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-05-10 13:01:58 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-05-10 13:01:58 -0700 |
commit | dc5ca74c88fd79e865d678367ee6a3ca7305624a (patch) | |
tree | 42c01231bf0c594036ba5d61626721db300b6579 | |
parent | c1b75e9e112f10fac77efc64028c74651fbc563b (diff) | |
download | mu-dc5ca74c88fd79e865d678367ee6a3ca7305624a.tar.gz |
1336
-rw-r--r-- | chessboard.mu | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/chessboard.mu b/chessboard.mu index 57df2b6e..878c122c 100644 --- a/chessboard.mu +++ b/chessboard.mu @@ -1,6 +1,24 @@ # chessboard program: takes moves in algebraic notation and displays the # position after each +# recipes are mu's names for functions, and recipes have ingredients +recipe main [ + switch-to-display # take control of screen and keyboard + + # The chessboard recipe takes keyboard and screen objects as 'ingredients'. + # + # In mu it is good form (though not required) to explicitly show the + # hardware you rely on. + # + # The chessboard also returns the same keyboard and screen objects. In mu it + # is good form to not modify ingredients of a recipe unless they are also + # results. Here we clearly modify both keyboard and screen, so we return + # both. + 0:literal/real-screen, 0:literal/real-keyboard <- chessboard 0:literal/real-screen, 0:literal/real-keyboard + + return-to-console # cleanup screen and keyboard +] + ## a board is an array of files, a file is an array of characters (squares) recipe init-board [ default-space:address:array:location <- new location:type, 30:literal @@ -574,9 +592,3 @@ recipe chessboard [ +quit #? $print [aaa] #? 1 ] - -recipe main [ - switch-to-display - 0:literal/real-screen, 0:literal/real-keyboard <- chessboard 0:literal/real-screen, 0:literal/real-keyboard - return-to-console -] |