diff --git a/Makefile b/Makefile
index 18f4517..d55a913 100644
--- a/Makefile
+++ b/Makefile
@@ -10,7 +10,6 @@ all: test
test:
@for luaver in $(LUA_VERSIONS); do \
- echo ""; \
echo "* $$luaver"; \
if ! command -v $$luaver > /dev/null 2>&1; then \
echo "$$luaver is not installed skippping"; \
diff --git a/dict.lua b/dict.lua
index e424b19..7d1e589 100644
--- a/dict.lua
+++ b/dict.lua
@@ -37,6 +37,11 @@ dict.defword("..", "ops.concat", false)
dict.defword(">a", "ops.to_aux", false)
dict.defword("a>", "ops.from_aux", false)
dict.defword("assert", "ops.assert", false)
+dict.defword("
", "ops.new_table", false)
+dict.defword("size", "ops.table_size", false)
+dict.defword("at", "ops.table_at", false)
+dict.defword("prepend", "ops.table_prepend", false)
+dict.defword("append", "ops.table_append", false)
dict.defword("if", "macros._if", true)
dict.defword("then", "macros._then", true)
dict.defword("else", "macros._else", true)
diff --git a/lib.eqx b/lib.eqx
index 7fa715d..bb23a69 100644
--- a/lib.eqx
+++ b/lib.eqx
@@ -1,6 +1,16 @@
-\ stack juggling
+: assert-true assert/1 drop ;
+: assert-false not assert-true ;
+: =assert = assert-true ;
+
\ TODO make them macros
: nip ( a b -- b ) swap drop ;
: 2dup ( a b -- a b a b ) over over ;
: -rot ( a b c -- c a b ) rot rot ;
: tuck ( a b -- b a b ) swap over ;
+
+: [ depth >a ;
+: ]
+ depth a> - 1 - 0
+ do
+ tuck prepend
+ loop ;
diff --git a/ops.lua b/ops.lua
index fc256e4..d0531a6 100644
--- a/ops.lua
+++ b/ops.lua
@@ -105,7 +105,7 @@ function ops.concat()
end
function ops.dot()
- io.write(stack:pop())
+ io.write(tostring(stack:pop()))
io.write(" ")
end
@@ -121,4 +121,30 @@ function ops.from_aux()
stack:push(aux:pop())
end
+function ops.new_table()
+ stack:push({})
+end
+
+function ops.table_size()
+ stack:push(#stack:pop())
+end
+
+function ops.table_at()
+ local n = stack:pop()
+ local t = stack:pop()
+ stack:push(t[n])
+end
+
+function ops:table_prepend()
+ local tbl = stack:pop()
+ local item = stack:pop()
+ table.insert(tbl, 1, item)
+end
+
+function ops:table_append()
+ local tbl = stack:pop()
+ local item = stack:pop()
+ table.insert(tbl, item)
+end
+
return ops
diff --git a/test_core.eqx b/test_core.eqx
index 13a90c9..3c1092f 100644
--- a/test_core.eqx
+++ b/test_core.eqx
@@ -1,7 +1,3 @@
-: assert-true assert/1 drop ;
-: assert-false not assert-true ;
-: =assert = assert-true ;
-
0 1 - -1 =assert
-10 1 + -9 =assert
-10 4 < assert-true
diff --git a/test_table.eqx b/test_table.eqx
new file mode 100644
index 0000000..958123a
--- /dev/null
+++ b/test_table.eqx
@@ -0,0 +1,16 @@
+[ ] size 0 =assert
+[ 1 ] size 1 =assert
+
+[ 3 5 7 "apple" [ 4 5 ] "banana" ] size 6 =assert
+
+: make-table [ 99 7 [ 9 6 ] "orange" "grapes" ] ;
+
+make-table size 5 =assert
+make-table 1 at 99 =assert
+make-table 2 at 7 =assert
+make-table 3 at 1 at 9 =assert
+make-table 3 at 2 at 6 =assert
+make-table 4 at "orange" =assert
+make-table 5 at "grapes" =assert
+
+depth 0 =assert