about summary refs log tree commit diff stats
path: root/hanoi.tlv
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-11-24 09:55:10 -0800
committerKartik K. Agaram <vc@akkartik.com>2021-11-24 10:10:38 -0800
commit5a63a5ca40c7ba05f7382c3da94bff8cc4b59976 (patch)
tree996cae425dbc830405b7b74625dbd26bd0b293e8 /hanoi.tlv
parentb40ad265448018d1a22d67db399568a2dfaf3cd2 (diff)
downloadteliva-5a63a5ca40c7ba05f7382c3da94bff8cc4b59976.tar.gz
monotonically accumulate versions of definitions
One old drawback now has a new look. Before, we loaded definitions in
order, so global definitions had to exist before other global
definitions that used them. See window and grid in life.tlv. Now we load
definitions in reverse order, so initialization needs to change. Worse,
if we update window, we need to edit grid just to fix the order.

This implies that we can't yet optimize away bindings where there are no
new changes.
Diffstat (limited to 'hanoi.tlv')
-rw-r--r--hanoi.tlv30
1 files changed, 28 insertions, 2 deletions
diff --git a/hanoi.tlv b/hanoi.tlv
index b08b200..cc1d33d 100644
--- a/hanoi.tlv
+++ b/hanoi.tlv
@@ -1,4 +1,5 @@
 teliva_program = {
+  {
     render = [==[
 function render(window)
   window:clear()
@@ -10,16 +11,25 @@ function render(window)
   end
   curses.refresh()
 end]==],
+  },
+  {
     lines = [==[
 function lines(window)
   local lines, cols = window:getmaxyx()
   return lines
 end]==],
+  },
+  {
     pop = [==[
 function pop(array)
   return table.remove(array)
 end]==],
-    window = [==[window = curses.stdscr()]==],
+  },
+  {
+    window = [==[
+window = curses.stdscr()]==],
+  },
+  {
     render_tower = [==[
 function render_tower(window, line, col, tower_index, tower)
   window:attron(curses.A_BOLD)
@@ -39,7 +49,12 @@ function render_tower(window, line, col, tower_index, tower)
     line = line - 1
   end
 end]==],
-    tower = [==[tower = {{6, 5, 4, 3, 2}, {}, {}}]==],
+  },
+  {
+    tower = [==[
+tower = {{6, 5, 4, 3, 2}, {}, {}}]==],
+  },
+  {
     render_disk = [==[
 function render_disk(window, line, col, size)
   col = col-size+1
@@ -50,6 +65,8 @@ function render_disk(window, line, col, size)
     col = col+2
   end
 end]==],
+  },
+  {
     main = [==[
 function main()
   for i=1,7 do
@@ -62,6 +79,8 @@ function main()
   end
 end
 ]==],
+  },
+  {
     len = [==[
 function len(array)
   local result = 0
@@ -70,6 +89,8 @@ function len(array)
   end
   return result
 end]==],
+  },
+  {
     update = [==[
 function update(window)
   window:mvaddstr(lines(window)-2, 5, "tower to remove top disk from? ")
@@ -78,14 +99,19 @@ function update(window)
   local to = curses.getch() - 96
   make_move(from, to)
 end]==],
+  },
+  {
     make_move = [==[
 function make_move(from, to)
   local disk = pop(tower[from])
   table.insert(tower[to], disk)
 end]==],
+  },
+  {
     cols = [==[
 function cols(window)
   local lines, cols = window:getmaxyx()
   return cols
 end]==],
+  },
 }