Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
-- This file:
-- http://angg.twu.net/sheavesforchildren/zhas.lua
-- http://angg.twu.net/sheavesforchildren/zhas.lua.html
--  (find-angg        "sheavesforchildren/zhas.lua")
--
-- (find-lua51manualw3m "")
-- (find-books "__comp/__comp.el" "ierusalimschy")
-- (find-pil2page 8 "Contents")
-- (find-pil2text 8 "Contents")

-- 2014jun20
-- A class for calculating with ZHAs.
-- Includes drawing tools, quick ways to compute and/or/imp/not/etc,
-- and a quick way to apply modalities.

-- «.ZHA»	(to "ZHA")
-- «.ZHA-tests»	(to "ZHA-tests")

coy = coroutine.yield
cow = coroutine.wrap



-- «ZHA» (to ".ZHA")
ZHA = Class {
  type    = "ZHA",
  specN   = function (spec)
      local copydigit = function (s) return s:sub(1, 1):rep(#s) end
      return (spec:gsub("[1-9][LRV]+", copydigit))
    end,
  fromspec = function (spec)
      local z = ZHA {spec = spec}
      z.specN = ZHA.specN(spec)
      z.maxy  = #spec - 1
      local relL, relR = 0, 0
      local minx, maxx = 0, 0
      for y=1,z.maxy do
        local a, deltaL, deltaR = z:yaction(y)
        relL = relL + deltaL
        relR = relR + deltaR
        minx = min(relL, minx)
        maxx = max(relR, maxx)
      end
      z.x0 = - minx
      z.L = {[0] = z.x0}
      z.R = {[0] = z.x0}
      z.maxx = - minx + maxx
      for y=1,z.maxy do
        local a, deltaL, deltaR = z:yaction(y)
        z.L[y] = z.L[y-1] + deltaL
        z.R[y] = z.R[y-1] + deltaR
      end
      return z
    end,
  fromspeclr = function (spec)
      return ZHA.fromspec(spec):calclrminmax()
    end,
  --
  __index = {
    yC = function (z, y) return          z.spec :sub(y+1, y+1)  end,
    yN = function (z, y) return tonumber(z.specN:sub(y+1, y+1)) end,
    yaction = function (z, y)
          if z:yC(y) == "L"         then return "L", -1, -1 end
          if z:yC(y) == "R"         then return "R",  1,  1 end
          if z:yC(y) == "V"         then return "V",  0,  0 end
          if z:yN(y) == z:yN(y-1)+1 then return "+", -1,  1 end
          if z:yN(y) == z:yN(y-1)-1 then return "-",  1, -1 end
        end,
    --
    -- Coordinates, both (x,y) and (l,r)
    xytol   = function (z, x, y) return (y - (x - z.x0)) / 2 end,
    xytor   = function (z, x, y) return (y + (x - z.x0)) / 2 end,
    xytolr0 = function (z, x, y) return z:xytol(x, y), z:xytor(x, y) end,
    xytolr  = function (z, x, y) return z:xytol(x, y)..z:xytor(x, y) end,
    lrtoxy0 = function (z, l, r) return r - l + z.x0, l + r end,
    lrtolr0 = function (z, lr)
        return tonumber(lr:sub(1, 1)), tonumber(lr:sub(2, 2))
      end,
    lrtoxy  = function (lr)
        local l, r = tonumber(lr:sub(1, 1)), tonumber(lr:sub(2, 2))
        return lrtoxy0(l, r)
      end,
    --
    -- Compute minl[], maxl[], minr[], maxr[], lrtop
    calclrminmax = function (z)
        z.minl, z.minr, z.maxl, z.maxr = {}, {}, {}, {}
        local minmax = function (a, b, c)
            return min((a or b), b), max(b, (c or b))
          end
        local lrminmax = function (l, r)
            z.minl[r], z.maxl[r] = minmax(z.minl[r], l, z.maxl[r])
            z.minr[l], z.maxr[l] = minmax(z.minr[l], r, z.maxr[l])
          end
        for y=0,z.maxy do
          lrminmax(z:xytolr0(z.L[y], y))
          lrminmax(z:xytolr0(z.R[y], y))
        end
        z.lrtop = z:xytolr(z.L[z.maxy], z.maxy)
        return z
      end,
    --
    -- Drawing (in ascii)
    lrline = function (z, y, f)
        f = f or function (lr) return lr end
        s = string.rep("  ", z.L[y]) .. f(z:xytolr(z.L[y], y))
        for x=z.L[y]+2,z.R[y],2 do s = s .. "  " .. f(z:xytolr(x, y)) end
        return s
      end,
    odotline = function (z, y)
        return string.rep(" ", z.L[y]).."o"..string.rep(".o", z:yN(y) - 1)
      end,
    drawf = function (z, f)
        for y=z.maxy,0,-1 do print(z:lrline(y, f)) end
        return z
      end,
    drawL = function (z, str) z:drawf(L(str)); return z end,
    drawE = function (z, str)
        local f = L(str)
        z:drawf(function (P) return Eq(P, f(P)) end)
        return z
      end,
    --
    -- Less or equal (e.g., for testing adjunctions)
    le = function (z, Plr, Qlr)
        local Pl, Pr = z:lrtolr0(Plr)
        local Ql, Qr = z:lrtolr0(Qlr)
        return Pl <= Ql and Pr <= Qr
      end,
    le11 = function (z, Plr, Qlr) return z:le(Plr, Qlr) and "11" or "00" end,
    --
    -- And, Or, Implies, Not
    lrand = function (z, Plr, Qlr)
        local Pl, Pr = z:lrtolr0(Plr)
        local Ql, Qr = z:lrtolr0(Qlr)
        return min(Pl, Ql)..min(Pr, Qr)
      end,
    lror = function (z, Plr, Qlr)
        local Pl, Pr = z:lrtolr0(Plr)
        local Ql, Qr = z:lrtolr0(Qlr)
        return max(Pl, Ql)..max(Pr, Qr)
      end,
    lrimp = function (z, Plr, Qlr)
        local Pl, Pr = z:lrtolr0(Plr)
        local Ql, Qr = z:lrtolr0(Qlr)
        if Pl <= Ql and Pr <= Qr then return z.lrtop end
        if Pl >  Ql and Pr >  Qr then return Qlr end
        if Pl <= Ql then return z.maxl[Qr]..Qr end
        if Ql <= Pl then return Ql..z.maxr[Ql] end
        return "??"
      end,
    lrnot = function (z, Plr) return z:lrimp(Plr, "00") end,
    --
    -- Modalities
    topmostbelowlr0 = function (z, l, r)
        if z.maxr[l] <= r then
          return l..min(z.maxr[l], r)
        else
          return min(z.maxl[r], l)..r
        end
      end,
    topmostbelowlr = function (z, lr)
        return z:topmostbelowlr0(z:lrtolr0(lr))
      end,
    modality0 = function (z, lstr, rstr, l, r)
        local newl = tonumber(lstr:sub(l+1, l+1))
        local newr = tonumber(rstr:sub(r+1, r+1))
        return z:topmostbelowlr0(newl, newr)
      end,
    modality = function (z, lstr, rstr, lr)
        return z:modality0(lstr, rstr, z:lrtolr0(lr))
      end,
    --
    -- Drawing the contour and cuts (in LaTeX)
    lrtopcoords = function (z, dl, dr, l, r)
        -- return format("(%3.1f,%3.1f)", l, r)
        -- return format("(%3.1f,%3.1f)", dl+l, dr+r)
        local newl,newr = dl+l, dr+r
        local x,y = z:lrtoxy0(newl, newr)
        return format("(%3.1f,%3.1f)", x, y)
      end,
    --
    outerangles0 = function (z)
        local left, right = {}, {}
        local l,r = 0,0
        while true do
          l = z.maxl[r]
          table.insert(left, {l=l, r=r});    print("left", l, r)
          r = z.minr[l + 1]
          if not r then break end
          table.insert(left, {l=l, r=r});    print("left", l, r)
        end
        local l,r = 0,0
        while true do
          r = z.maxr[l]
          table.insert(right, {l=l, r=r});    print("right", l, r)
          l = z.minl[r + 1]
          if not l then break end
          table.insert(right, {l=l, r=r});    print("right", l, r)
        end
        return left, right
      end,
    leftcut0  = function (z, l) return z.minr[l+1], z.maxr[l] end,
    rightcut0 = function (z, l) return z.minl[r+1], z.maxr[l] end,
    --
    outerangles = function (z)
        local path = {}
        local corner = function (dl, dr, l, r)
            -- table.insert(path, format("(%f,%f)", l, r))
            table.insert(path, z:lrtopcoords(dl, dr, l, r))
          end
        corner(-0.5, -0.5, 0, 0)
        local ltop, rtop = z:lrtolr0(z.lrtop)
        local left, right = z:outerangles0()
        for _,lr in ipairs(left) do
          corner(0.5, -0.5, lr.l, lr.r)
        end
        corner(0.5, 0.5, ltop, rtop)
        for i=#right,1,-1 do
          local lr = right[i]
          corner(-0.5, 0.5, lr.l, lr.r)
        end
        corner(-0.5, -0.5, 0, 0)
        return "  \\draw[outer] "..table.concat(path, " -- ")..";\n"
      end,
    leftcut = function (z, l)
        local r1, r2 = z.minr[l+1], z.maxr[l]
        return "  \\draw[cut] "..z:lrtopcoords(0.5, -0.5, l, r1).." -- "..
                                 z:lrtopcoords(0.5,  0.5, l, r2)..";\n"
      end,
    rightcut = function (z, r)
        local l1, l2 = z.minl[r+1], z.maxl[r]
        return "  \\draw[cut] "..z:lrtopcoords(-0.5, 0.5, l1, r).." -- "..
                                 z:lrtopcoords( 0.5, 0.5, l2, r)..";\n"
      end,
    --
    genpoints = function (z)
        return cow(function ()
            for y=z.maxy,0,-1 do
              for x=z.L[y],z.R[y],2 do
                local l,r = z:xytolr0(x,y)
                coy(z, x, y, l, r)
              end
            end
          end)
      end,
  },
}

-- Make (f*g)(a, b, c) behave as f(g(a, b, c))
-- See: (find-LATEX "2014-1-GA-P2-gab.lua")
debug.setmetatable (print, {
    __mul = function (f, g) return
        function (...) return f(g(...)) end
      end,
  })

-- Lambda
eval = function (str) return assert(loadstring(str))() end
expr = function (str) return eval("return "..str) end
L00 = function (args, body)
    return string.format("function (\%s) return \%s end", args, body)
  end
L0 = function (str)
    local args, body = str:match("^\%s*(\%S+)\%s+(.*)$")
    return L00(args, body)
  end
L = function (str) return expr(L0(str)) end

-- Shorthands for some operations
Le  = function (P, Q) return z:le11 (P, Q) end
Or  = function (P, Q) return z:lror (P, Q) end
And = function (P, Q) return z:lrand(P, Q) end
Imp = function (P, Q) return z:lrimp(P, Q) end
Not = function (P) return z:lrnot(P) end
Top = function () return z.lrtop end

Eq  = function (P, Q) return P==Q and '11' or '00' end


-- Elementary J-operators
-- (find-books "__cats/__cats.el" "fourman")
-- (find-slnm0753page (+ 14 329)   "2.18 Elementary J-operators")
Jo  = function (P) return
    function (Q) return Or(P, Q) end
  end
Ji  = function (P) return
    function (Q) return Imp(P, Q) end
  end
Jb  = function (R) return
    function (Q) return Imp(Imp(Q, R), R) end
  end
Jf  = function (P, Q) return
    function (R) return And(Or(P, R), Imp(Q, R)) end
  end

Jand = function (J1, J2) return
    function (P) return And(J1(P), J2(P)) end
  end
Jor = function (J1, J2) return
    function (P) return Or(J1(P), J2(P)) end
  end

-- The generic J-operator:
Jm = function (lstr, rstr) return
    function (Q) return z:modality(lstr, rstr, Q) end
  end

-- M = L "P z:modality('1133556', '02244', P)"
-- M = Jm("1133556", "02244")



--[[
-- «ZHA-tests» (to ".ZHA-tests")
-- (find-books "__cats/__cats.el" "slnm0753")

* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "zhas.lua"

z = ZHA.fromspec   "123LL432L1"
z = ZHA.fromspeclr("123LL432L1"):drawf()
z:drawL "P           Not(P)  "
z:drawL "P       Not(Not(P)) "
z:drawL "P Eq(P, Not(Not(P)))"
z:drawL "P And(P, '21')"
z:drawL "P Imp(P, '21')"
z:drawL "P Imp('21', P)"
z:drawL "P Le('21', P)"
z:drawL "P Le(P, '21')"

-- Test my definition of "implies":
-- For every Q and R the two "draw"s below
-- should draw the same down-set.
Q, R = "20", "11"
Q, R = "20", "00"
z:drawL "P Le(And(P, Q), R)"
z:drawL "P Le(P, Imp(Q, R))"


* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "zhas.lua"
z = ZHA.fromspeclr("1234567654321"):drawf()
My = Jm("0123456", "0123456")
My = Jm("0133456", "0144456")
z:drawf(L "P Eq(P, My(P))")
z:drawL   "P Eq(P, My(P))"
z:drawE   "P       My(P) "

-- (find-books "__cats/__cats.el" "fourman")
-- (find-slnm0753page (+ 14 329) "2.18 Elementary J-operators")
-- (find-slnm0753page (+ 14 329) "(i)  J_a p = a v p")
-- (find-slnm0753page (+ 14 330) "(ii) J^a p = a -> p")

z:drawE "P                Jo'25' (P)"
z:drawE "P        Jo'41'         (P)"
z:drawE "P                Ji'25' (P)"
z:drawE "P        Ji'41'         (P)"

-- (find-slnm0753page (+ 14 331) "(i) J_a v J_b = J_avb")
z:drawE "P Jor(Jo'41',  Jo'25')(P)"
z:drawE "P Jo(Or('41',   '25'))(P)"

-- (find-slnm0753page (+ 14 331) "(ii) J^a v J^b = J_a&b")
z:drawE "P Jor(Ji'41', Ji'25')(P)"
z:drawE "P Ji(And('41',  '25'))(P)"

-- (find-slnm0753page (+ 14 331) "(iii) J_a & J_b = J_a&b")
z:drawE "P Jand(Jo'41',  Jo'25')(P)"
z:drawE "P Jo(And('41',   '25'))(P)"

-- (find-slnm0753page (+ 14 331) "(iv) J^a & J^b = J^avb")
z:drawE "P Jand(Ji'41', Ji'25')(P)"
z:drawE "P Ji(Or('41',  '25'))(P)"

-- (find-slnm0753page (+ 14 331) "(v) J_a & J^a = bot")
z:drawE "P Jand(Jo'41', Ji'41')(P)"

-- (find-slnm0753page (+ 14 331) "(vi) J_a v J^a = top")
z:drawE "P Jor(Jo'41', Ji'41')(P)"

-- (find-slnm0753page (+ 14 331) "(vii) J_a v K = K o J_a")
z:drawE "P Jor(Jo'41', My)(P)"
z:drawE "P My(Jo'41'(P))"

-- (find-slnm0753page (+ 14 331) "(viii) J^a v K = J_a o K")
z:drawE "P Jor(Ji'41', My)(P)"
z:drawE "P Ji'41'(My(P))"

-- (find-slnm0753page (+ 14 331) "(ix) J_a v B_a = B_a")
z:drawE "P Jor(Jo'41', Jb'41')(P)"
z:drawE "P Jb'41'(P)"

-- (find-slnm0753page (+ 14 331) "(x) J^a v B_b = B_a->b")
z:drawE "P Jor(Ji'41', Jb'25')(P)"
z:drawE "P Jb(Imp('41', '25'))(P)"

z:drawE "P Jand(Jb'44', Jb'22')(P)"
z:drawE "P Jand(Jand(Jb'44', Jb'22'), Jb'00')(P)"



z:drawE "P Ji(Or('41',  '25'))(P)"
z:drawE "P Ji(Or('41',  '25'))(P)"
z:drawE "P Jb('23')(P)"
z:drawE "P Jb('41', '25')(P)"
z:drawE "P   Jand(Jo'41', Jo'25')(P)         "
z:drawE "P   Jo(And('41',  '25'))(P)         "
z:drawf(L "P Eq(P,     Jo'41'(P))            ")
z:drawf(L "P Eq(P,                Jo'25'(P)) ")
z:drawf(L "P Eq(P, And(Jo'41'(P), Jo'25'(P)))")
z:drawf(L "P Eq(P, Jo(And('41',   '25'))(P)) ")
z:drawf(L "P Eq(P,     Ji'41'(P))            ")
z:drawf(L "P Eq(P,                Ji'25'(P)) ")
z:drawf(L "P Eq(P, And(Ji'41'(P), Ji'25'(P)))")
z:drawf(L "P Eq(P, Jo(And('41',   '25'))(P)) ")

-- M = Jm("1133556", "02244")



* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "zhas.lua"
z = ZHA.fromspeclr("123LLLRRRLL21"):drawf()
= z:outerangles()

= z:outerangles()..
  z:leftcut(0)..
  z:leftcut(2)..
  z:leftcut(3)..
  z:rightcut(0)..
  z:rightcut(1)..
  z:rightcut(2)

for z,x,y,l,r in z:genpoints() do
  -- print(x,y,l,r)
  printf("\\draw[color=red] (%d,%d) -- (%d,%d);\n", x, y, x, y+1);
end

for z,x,y,l,r in z:genpoints() do
  printf("\\draw (%d,%d) node {\\scriptsize %d%d};\n", x, y, l, r);
end

draw = function (str) print("  \\draw "..str..";") end
do
draw(z:outerangles())
draw(z:leftcut(0))
draw(z:leftcut(2))
draw(z:leftcut(3))
draw(z:rightcut(0))
draw(z:rightcut(1))
draw(z:rightcut(2))
end



#*
# (defun c  () (interactive) (eev-bounded) (find-zsh0 "ee"))
# (defun cc () (interactive) (eev-bounded) (find-zsh  "ee"))
# (defun d  () (interactive) (find-xpdfpage "/tmp/tikz/test1.pdf"))
# (find-angg ".emacs.papers" "tikz")

mkdir /tmp/tikz/
cd    /tmp/tikz/
cat > test1.tex <<'%%%'
\documentclass{book}
\usepackage{tikz}
\usepackage{luacode}
\begin{document}
\tikzset{axis/.style=very thick}
\tikzset{tick/.style=thick}
\tikzset{grid/.style=gray,very thin}
\tikzset{outer/.style=gray,very thin}
\tikzset{cut/.style=very thick}
%
Hello:%
\begin{tikzpicture}[scale=0.33]
  % \clip (-2-0.4, -3-0.4) rectangle (4+0.4, 5+0.4);
  % \draw[step=1cm,grid] (-2,-3) grid (4,5);
  % \draw[axis] (-10,0) -- (10,0);
  % \draw[axis] (0,-10) -- (0,10);
  % \foreach \x in {-10,...,10} \draw[tick] (\x,-0.2) -- (\x,0.2);
  % \foreach \y in {-10,...,10} \draw[tick] (-0.2,\y) -- (0.2,\y);
  %
  \draw[outer] (5.0,-1.0) -- (-1.0,5.0) -- (2.0,8.0) -- (0.0,10.0) -- (3.0,13.0) -- (8.0,8.0) -- (5.0,5.0) -- (8.0,2.0) -- (5.0,-1.0);
  % \draw[color=red] (5,0) -- (5,1);
  \draw[cut] (4.0,0.0) -- (7.0,3.0);
  \draw[cut] (2.0,2.0) -- (5.0,5.0);
  \draw[cut] (1.0,3.0) -- (7.0,9.0);
  \draw[cut] (6.0,0.0) -- (0.0,6.0);
  \draw[cut] (7.0,1.0) -- (1.0,7.0);
  \draw[cut] (5.0,5.0) -- (2.0,8.0);
  %
\draw (3,12) node {\scriptsize 75};
\draw (2,11) node {\scriptsize 74};
\draw (4,11) node {\scriptsize 65};
\draw (1,10) node {\scriptsize 73};
\draw (3,10) node {\scriptsize 64};
\draw (5,10) node {\scriptsize 55};
\draw (2,9) node {\scriptsize 63};
\draw (4,9) node {\scriptsize 54};
\draw (6,9) node {\scriptsize 45};
\draw (3,8) node {\scriptsize 53};
\draw (5,8) node {\scriptsize 44};
\draw (7,8) node {\scriptsize 35};
\draw (2,7) node {\scriptsize 52};
\draw (4,7) node {\scriptsize 43};
\draw (6,7) node {\scriptsize 34};
\draw (1,6) node {\scriptsize 51};
\draw (3,6) node {\scriptsize 42};
\draw (5,6) node {\scriptsize 33};
\draw (0,5) node {\scriptsize 50};
\draw (2,5) node {\scriptsize 41};
\draw (4,5) node {\scriptsize 32};
\draw (1,4) node {\scriptsize 40};
\draw (3,4) node {\scriptsize 31};
\draw (5,4) node {\scriptsize 22};
\draw (2,3) node {\scriptsize 30};
\draw (4,3) node {\scriptsize 21};
\draw (6,3) node {\scriptsize 12};
\draw (3,2) node {\scriptsize 20};
\draw (5,2) node {\scriptsize 11};
\draw (7,2) node {\scriptsize 02};
\draw (4,1) node {\scriptsize 10};
\draw (6,1) node {\scriptsize 01};
\draw (5,0) node {\scriptsize 00};
  %
\end{tikzpicture}%
:bye

\end{document}
%%%
lualatex test1.tex
#*



z = ZHA.fromspeclr("123LLLRRRLL21"):drawf()
= leftcut(z, 0)
= leftcut(z, 2)
= leftcut(z, 3)
= rightcut(z, 0)
= rightcut(z, 1)
= rightcut(z, 2)


PP(z)

M = Jm("11335567", "022445")
z:drawE("P M(P)")

z = ZHA.fromspeclr("12LLLRRRLL1"):drawf()
M = Jm("1133556", "02244")
z:drawf(L "P Eq(P, M(P))")








* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "zhas.lua"
z = ZHA.fromspeclr("12LLLRRRLL1"):drawf()
= z:topmostbelowlr("13")
= z:topmostbelowlr("61")
= z:topmostbelowlr("43")

M = L "P z:modality('1133556', '02244', P)"

z:drawf(L "P M(P)")
z:drawf(L "P M(P)==P and '11' or '00'")
z:drawf(L "P Eq(M(P), P)")


* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "zhas.lua"

z = ZHA.fromspeclr("123LL432L1"):drawf()



z = ZHA.fromspeclr "123454321"


z:calclrminmax()
PP(z)
for y=z.maxy,0,-1 do print(z:lrline(y)) end

f = function (Q) return z:lrimp(Q, "22") end
f = L "Q z:lrimp(Q, '22')"
f = L "Q And(Q, '22')"
for y=z.maxy,0,-1 do print(z:lrline(y, f)) end

for y=z.maxy,0,-1 do print(z:lrline(y, L "Q And(Q, '22')")) end
for y=z.maxy,0,-1 do print(z:lrline(y, L "Q And(Q, '11')")) end
for y=z.maxy,0,-1 do print(z:lrline(y, L "Q Imp(Q, '22')")) end
for y=z.maxy,0,-1 do print(z:lrline(y, L "Q Imp('22', Q)")) end

z:drawf(L "Q Imp(Q, '22')")

f = L "Q And(Or(Q, '31'), Or(Q, '13'))"
for y=z.maxy,0,-1 do print(z:lrline(y, f)) end

f = L "Q And(Or(Q, '11'), Or(Q, '33'))"
for y=z.maxy,0,-1 do print(z:lrline(y, f)) end

z = ZHA.fromspeclr("12LLLRRR1"):drawf()
= z:topmostbelowlr("13")







-- Old:

* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "zhas.lua"

z = ZHA{spec="1V21"}
PP(z)
PP(z:calcLR())
= z.str

= ZHA{spec="1V21"}:calcLR().str
= ZHA{spec="1234R3RLL21"}:calcLR().str
z=ZHA{spec="1234R3RLL21"}:calcLR()
PP(z)
= z.ystr[4]
= z.ystr[4]:gsub("()%.", function (a) print(a) return "!" end)

= z:slashstr("/____", [=[\\___]=])
= z:slashstr("////_", [=[\\\\_]=])
= z:ddstr()


slashize


= tonumber "k"
= tonumber "l"
= tonumber "r"
= tonumber "v"


 o/ / / / / / /
 /o/
  Xo
  o\o
 o.o\o/
  o.oXo
   o/o\o
 \o/o.o
 oXo.o.o
o/o\o.o
/o.o\o
  o.o\
   o\ \ \ \ \ \_

   /o
  /o\o
 <o.o\o
  \o.oXo
   >o/o\o
  /o/o.o
 /oXo.o.o
/o/o\o.o
 o.o\o
  o.o
   o



   \o.
  .o\o.
  o.o\o/
  .o.oXo.
   .o/o\o
  \o/o.o\
 .oXo.o.o
 o/o\o.o.
 /o.o\o.
  .o.o\
   .o.




--]]

--[====[

* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
ZPic = Class {
  type = "ZPic",
  new  = function (zha, lower)
    end,
    globaldefs = function ()
      return [[
        \newdimen\mypictureunit
        \setbox0=\hbox{\rm0}
        \mypictureunit=.085\wd0
]]
      end,
  __index = {
    params4 = function (p)
        local sh,sv,dh,dv = 7*p.zha.maxx+12, 7*p.zha.maxy+12, -6, 0
        return format("(%d,%d)(%d,%d)", sh, sv, dh, dv)
      end,
    params = function (zha)
        local sh,sv,dh,dv,lv = 7*maxx+12, 7*maxy+12, -6, 0, (lower or 0)*7
        return format("(%d,%d)(%d,%d)[%3.1f]", sh, sv, dh, dv, lv)
      end,
    dagpic0 = function (p,sh,sv,dh,dv,lower,body)
        local template = [[
\ensuremath{%
  \unitlength=!UNITLENGTH
  \lower!LOWER\unitlength\hbox{%
    \begin{picture}(!SH,!SV)(!DH,!DV)
      !BODY
    \end{picture}%
  }}]]
        local A = { UNITLENGTH="0.85ex",
          SH=sh, SV=sv, DH=dh, DV=dv, LOWER=lower,
          BODY=body }
        return (template:gsub("!([A-Z]+)", A))
      end,
  },
}

= foo(2,3,4,5,6,7)

= ZPic {}
= ZPic {} :dagpic0(2,3,4,5,6,7)




params 




dagpictureheader0 = function (maxx, maxy, lower)
    local sh = 7*maxx + 12
    local sv = 7*maxy + 12
    local dh = -6
    local dv = 0
    local lv = (lower or 0)* 7
    return format("(%d,%d)(%d,%d)[%3.1f]", sh, sv, dh, dv, lv)
  end
bdagpictureheader = function (maxx, maxy, lower)
    return "\\bdagpicture"..dagpictureheader0(maxx, maxy, lower)
  end
dc = function (x, y)
    local h = 7*x
    local v = 7*y
    return format("(%d,%d)", h, v)
  end
dagputheader = function (x, y)
    return format("\\dagput(%d,%d)", 7*x, 7*y)
  end

--]====]




-- Local Variables:
-- coding: raw-text-unix
-- End: