about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-11-06 10:57:40 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-11-06 10:57:40 -0700
commit2b580e41745900aeaef000f575c26f127d30bca2 (patch)
treeca2c9938792ea123cefae2cff918cee98403a595
parent3e1c9986d7533bf00ce0d5bdfc61a7dc1ccbb867 (diff)
downloadteliva-2b580e41745900aeaef000f575c26f127d30bca2.tar.gz
adjust app style a tad denser
-rw-r--r--hanoi.lua27
-rw-r--r--hanoi.teliva23
2 files changed, 16 insertions, 34 deletions
diff --git a/hanoi.lua b/hanoi.lua
index 7a5a938..f216570 100644
--- a/hanoi.lua
+++ b/hanoi.lua
@@ -1,9 +1,7 @@
 local curses = require "curses"
 
-
 tower = {{6, 5, 4, 3, 2}, {}, {}}
 
-
 local function len(array)
   local result = 0
   for k in pairs(array) do
@@ -12,7 +10,6 @@ local function len(array)
   return result
 end
 
-
 local function pop(array)
   return table.remove(array)
 end
@@ -57,7 +54,6 @@ local function render_tower(window, line, col, tower_index, tower)
   end
 end
 
-
 local function render(window)
   window:clear()
   local lines, cols = window:getmaxyx()
@@ -75,7 +71,6 @@ local function make_move(from, to)
   table.insert(tower[to], disk)
 end
 
-
 local function update(window)
   window:mvaddstr(lines(window)-2, 5, "tower to remove top disk from? ")
   local from = string.byte(curses.getch()) - 96
@@ -87,20 +82,16 @@ local function update(window)
 end
 
 
-local function main()
-  local window = curses.initscr()
-  curses.start_color()
-  for i=1,7 do
-    curses.init_pair(i, 0, i)
-  end
-
-  while true do
-    render(window)
-    update(window)
-  end
+window = curses.initscr()
+curses.start_color()
+for i=1,7 do
+  curses.init_pair(i, 0, i)
+end
 
-  curses.endwin()
+while true do
+  render(window)
+  update(window)
 end
 
+curses.endwin()
 
-main()
diff --git a/hanoi.teliva b/hanoi.teliva
index ba1d9cc..04b4491 100644
--- a/hanoi.teliva
+++ b/hanoi.teliva
@@ -1,9 +1,7 @@
 local curses = require "curses"
 
-
 tower = {{6, 5, 4, 3, 2}, {}, {}}
 
-
 local function len(array)
   local result = 0
   for k in pairs(array) do
@@ -12,7 +10,6 @@ local function len(array)
   return result
 end
 
-
 local function pop(array)
   return table.remove(array)
 end
@@ -57,7 +54,6 @@ local function render_tower(window, line, col, tower_index, tower)
   end
 end
 
-
 local function render(window)
   window:clear()
   local lines, cols = window:getmaxyx()
@@ -75,7 +71,6 @@ local function make_move(from, to)
   table.insert(tower[to], disk)
 end
 
-
 local function update(window)
   window:mvaddstr(lines(window)-2, 5, "tower to remove top disk from? ")
   local from = curses.getch() - 96
@@ -87,17 +82,13 @@ local function update(window)
 end
 
 
-local function main()
-  local window = curses.stdscr()
-  for i=1,7 do
-    curses.init_pair(i, 0, i)
-  end
-
-  while true do
-    render(window)
-    update(window)
-  end
+local window = curses.stdscr()
+for i=1,7 do
+  curses.init_pair(i, 0, i)
 end
 
+while true do
+  render(window)
+  update(window)
+end
 
-main()