Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
-- This file:
--   http://angg.twu.net/LATEX/2021-2-C3-diag-nums.lua.html
--   http://angg.twu.net/LATEX/2021-2-C3-diag-nums.lua
--           (find-angg "LATEX/2021-2-C3-diag-nums.lua")
-- Author: Eduardo Ochs <eduardoochs@gmail.com>
--
-- (defun e  () (interactive) (find-LATEX "2021-2-C3-diag-nums.tex"))
-- (defun l  () (interactive) (find-LATEX "2021-2-C3-diag-nums.lua"))
-- (defun gp () (interactive) (find-LATEX "2021-2-C3-diag-nums.gnuplot"))
--
-- Superseded by: (find-angg "LUA/CabosNaDiagonal.lua")

bigstr = [[
  0 - 0 - 0 - 1 - 2 - 3
  | . | . | . | . | / |
  0 - 0 - 0 - 1 - 2 - 2
  | . | . | . | \ | . |
  0 - 0 - 0 - 1 - 1 - 1
  | . | . | / | . | . |
  0 - 0 - 0 - 0 - 0 - 0
  | . | . | . | . | . |
  0 - 0 - 0 - 0 - 0 - 0
  | . | . | . | . | . |
  0 - 0 - 0 - 0 - 0 - 0
]]
bigarr = map(split, splitlines(bigstr))
bigget = function (x, y)
    local a = #bigarr - y*2
    local b = x*2 + 1
    -- print(a, b)
    return bigarr[a][b]
  end

xyz = function (x, y)
    return format("%s,%s,%s", x, y, bigget(x, y))
  end

vertices = function (x, y)
    local nw, ne = xyz(x, y+1), xyz(x+1, y+1)
    local sw, se = xyz(x, y),   xyz(x+1, y) 
    middle = bigget(x+0.5, y+0.5)
    return nw, ne, sw, se, middle
  end

square = function (nw, ne, sw, se)
    return format("%s to %s to %s to %s to %s", sw, se, ne, nw, sw)
  end
triangles = function (nw, ne, sw, se, middle)
    if middle == "/" then
      return format("%s to %s to %s to %s", sw, ne, nw, sw),
             format("%s to %s to %s to %s", sw, se, ne, sw)
    elseif middle == "\\" then
      return format("%s to %s to %s to %s", sw, se, nw, sw),
             format("%s to %s to %s to %s", se, ne, nw, se)
    else PP("bad middle", middle); error()
    end
  end

n = 0
nincr = function () n = n+1; return n end

squareortriangle = function (x,y)
    local nw, ne, sw, se, middle = vertices(x, y)
    if middle == "." then
      local sq = square(nw, ne, sw, se)
      return format("set obj %d polygon from %s", nincr(), sq)
    else
      local tri1, tri2 = triangles(nw, ne, sw, se, middle)
      return format("set obj %d polygon from %s\n", nincr(), tri1)
          .. format("set obj %d polygon from %s",   nincr(), tri2)
    end
  end



--[[
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "2021-2-C3-diag-nums.lua"
PPV(bigarr)
= bigget(0,0)
= bigget(0,1)
= bigget(1,1)
= bigget(3,3)
= bigget(2.5,2.5)
= vertices(3,3)
= vertices(4,3)

= squareortriangle(2,2)
= squareortriangle(2,0)

for x=0,4 do
  for y=0,4 do
    print(squareortriangle(x, y))
  end
end

--]]





-- Local Variables:
-- coding:  utf-8-unix
-- End: