about summary refs log tree commit diff stats
path: root/pp.lua
diff options
context:
space:
mode:
authorCase Duckworth2024-04-03 22:45:59 -0500
committerCase Duckworth2024-04-03 22:45:59 -0500
commit235026f7d5893be5c3e2307e6dc61424e1aa91d2 (patch)
tree68e86924787d5c13a3dd01f925a703dea2c9eadf /pp.lua
parentProtect evaluation within repl (diff)
downloadlam-235026f7d5893be5c3e2307e6dc61424e1aa91d2.tar.gz
lam-235026f7d5893be5c3e2307e6dc61424e1aa91d2.zip
Change pp -> dump
Keep them 4 letter file name boiiii
Diffstat (limited to 'pp.lua')
-rw-r--r--pp.lua37
1 files changed, 0 insertions, 37 deletions
diff --git a/pp.lua b/pp.lua deleted file mode 100644 index 4d9d9af..0000000 --- a/pp.lua +++ /dev/null
@@ -1,37 +0,0 @@
1--- lam.pp
2
3local pp = {}
4local type = require "type"
5local unpack = table.unpack or unpack
6
7function pp.dump (x, lvl)
8 lvl = lvl or 0
9 local space = string.rep(" ", lvl)
10 local output = ""
11 --[[if getmetatable(x) and getmetatable(x).__tostring then
12 output = output .. tostring(x)
13 else]]if type.luatype(x) == "table" then
14 local subo = ""
15 for k,v in pairs(x) do
16 if v == x then
17 v = "self"
18 else
19 v = pp.dump(v, lvl+2)
20 end
21 subo = subo .. string.format("\n%s[%s] = %s,",
22 (space.." "), k, v)
23 end
24 output = output .. string.format("\n%s{%s\n%s}",
25 space, subo, space)
26 else
27 output = output .. tostring(x)
28 end
29 return output
30end
31
32function pp.pp (x)
33 print(pp.dump(x))
34end
35
36---
37return pp