about summary refs log tree commit diff stats
path: root/pp.lua
diff options
context:
space:
mode:
authorCase Duckworth2024-03-04 21:01:27 -0600
committerCase Duckworth2024-03-04 21:01:27 -0600
commitbbaff0e0c204c2fab216f6501dc8c11b4425b4bc (patch)
treeb2a06edc7b1c8e6f86839bff8c16e06297080674 /pp.lua
parentAdd copying (diff)
downloadlam-bbaff0e0c204c2fab216f6501dc8c11b4425b4bc.tar.gz
lam-bbaff0e0c204c2fab216f6501dc8c11b4425b4bc.zip
Ugghhhh totally not working first-try
Diffstat (limited to 'pp.lua')
-rw-r--r--pp.lua22
1 files changed, 18 insertions, 4 deletions
diff --git a/pp.lua b/pp.lua index 85d323e..9c1a6d0 100644 --- a/pp.lua +++ b/pp.lua
@@ -3,11 +3,27 @@
3local pp = {} 3local pp = {}
4table.unpack = table.unpack or unpack 4table.unpack = table.unpack or unpack
5 5
6pp.luadump =
7 function (x)
8 end
9
10pp.luapp = function (x) print(pp.luadump(x)) end
11
12pp.lamdump =
13 function (x)
14 end
15
16pp.lampp = function (x) print(pp.lamdump(x)) end
17
18-- The following should be at some point replaced by the preceding
19
6function pp.dump (x, lvl) 20function pp.dump (x, lvl)
7 lvl = lvl or 0 21 lvl = lvl or 0
8 local space = string.rep(" ", lvl) 22 local space = string.rep(" ", lvl)
9 local output = "" 23 local output = ""
10 if type(x) == "table" then 24 --[[if getmetatable(x) and getmetatable(x).__tostring then
25 output = output .. tostring(x)
26 else]]if type(x) == "table" then
11 local subo = "" 27 local subo = ""
12 for k,v in pairs(x) do 28 for k,v in pairs(x) do
13 if v == x then 29 if v == x then
@@ -20,10 +36,8 @@ function pp.dump (x, lvl)
20 end 36 end
21 output = output .. string.format("\n%s{%s\n%s}", 37 output = output .. string.format("\n%s{%s\n%s}",
22 space, subo, space) 38 space, subo, space)
23 elseif type(x) == "string" then
24 output = output .. string.format("'%s'", x)
25 else 39 else
26 output = output .. string.format("%s", x) 40 output = output .. tostring(x)
27 end 41 end
28 return output 42 return output
29end 43end