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

-- (find-es "lua5" "histogram")
-- (find-es "lua5" "histograms")


letters = "ABCDEFGHIJ"
L = function (n) return letters:sub(n,n) end
V = {3, 3, 5, 5, 6, 6, 7, 7, 9, 9}
histo = {
  addpoint = function (histo, x, name)
      if not x then error() end
      histo.minx = histo.minx and min(histo.minx, x) or x
      histo.maxx = histo.maxx and max(histo.maxx, x) or x
      histo[x] = histo[x] or {}
      table.insert(histo[x], name)
      local y = #(histo[x])
      histo.maxy = histo.maxy and max(histo.maxy, y) or y
    end,
  point = function (histo, x, y)
      if y==0 then return format("%4.1f ", x/5) end
      return (histo[x] or {})[y] or "     "
    end,
  line = function (histo, y)
      local T = {}
      for x=histo.minx, histo.maxx do
        table.insert(T, histo:point(x, y))
      end
      return table.concat(T, " ")
    end,
}

addpoints = function ()
    n = 0
    for a=1,10 do
      for b=a+1,10 do
        for c=b+1,10 do
          for d=c+1,10 do
            for e=d+1,10 do
              name = L(a)..L(b)..L(c)..L(d)..L(e)
              tot  = V[a]+V[b]+V[c]+V[d]+V[e]
              n = n+1
              -- histo[tot] = histo[tot] or {}
              -- table.insert(histo[tot], name)
              histo:addpoint(tot, name)
              print(n, name)
            end
          end
        end
      end
    end
  end

print1 = function ()
    for tot=histo.minx,histo.maxx do
      print(tot, table.concat(histo[tot], " "))
    end
  end

print2 = function ()
    for tot=histo.minx,histo.maxx do
      print(tot/5, #(histo[tot]))
    end
  end

print3 = function ()
    for y=histo.maxy,0,-1 do
      print(histo:line(y))
    end
  end

doall = function ()
    addpoints()
    PP(histo)
    print1()
    print2()
    print3()
  end


--[[
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "2013.2-ES-diags"
V = {3, 3, 3, 3, 4, 4, 4, 6, 6, 9}
V = {3, 3, 3, 4, 4, 5, 6, 6, 8, 8}
addpoints()
PP(histo)
print1()
print2()
print3()
* (eek "C-x 0 21*<up> C-l")

* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "2013.2-ES-diags"
V = {3, 3, 3, 4, 4, 5, 6, 6, 7, 8}
V = {3, 3, 3, 4, 4, 5, 6, 6, 8, 8}
doall()
* (eek "C-x 0 21*<up> C-l")

--]]


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