4 ms·
The ConTeXt typesetting system tightly integrates Lua. One aspect of Lua I dislike is that it isn't object-oriented. What's impressive is that the language can
by thangalin 3y ago
The ConTeXt typesetting system tightly integrates Lua. One aspect of Lua I dislike is that it isn't object-oriented. What's impressive is that the language can be extended to be so in astonishingly little code:
* https://github.com/kikito/middleclass/blob/master/middleclass.lua https://github.com/kikito/middleclass/blob/master/middleclas...
Using OOP, typesetting a hexagonal grid and a symbolic representation of a neural network on top is easier develop, IMO.
A vertex defines a point in 2D space:
* https://github.com/DaveJarvis/keenwrite-themes/blob/main/boschet/Vertex.lua https://github.com/DaveJarvis/keenwrite-themes/blob/main/bos...
An edge connects two vertices:
* https://github.com/DaveJarvis/keenwrite-themes/blob/main/boschet/Edge.lua https://github.com/DaveJarvis/keenwrite-themes/blob/main/bos...
A graph connects edges:
* https://github.com/DaveJarvis/keenwrite-themes/blob/main/boschet/Graph.lua https://github.com/DaveJarvis/keenwrite-themes/blob/main/bos...
A priority queue serves for ordering edges by weight of adjoining vertices:
* https://github.com/DaveJarvis/keenwrite-themes/blob/main/boschet/PriorityQueue.lua https://github.com/DaveJarvis/keenwrite-themes/blob/main/bos...
With these concepts in hand, we can typeset a grid and a "neural network" on top:
* https://github.com/DaveJarvis/keenwrite-themes/blob/main/boschet/perceptron.tex https://github.com/DaveJarvis/keenwrite-themes/blob/main/bos...
Here's an example of the output from the first chapter:
* https://i.ibb.co/19DCDZy/ch-1.png https://i.ibb.co/19DCDZy/ch-1.png
And a later chapter, where the "network" has grown in complexity:
* https://i.ibb.co/ncf16vg/ch-2.png https://i.ibb.co/ncf16vg/ch-2.png
This is for my near future hard sci-fi book on AGI. I'm looking for alpha readers to give me feedback. See profile for contact details.
P.S.
There's a subtle bug in the code that can result in one or two disconnected vertices. If you spot it, let me know!
- Rochus 3y agoIt's actually not ConTeXt which integrates Lua, but LuaTeX; ConTeXt is based on the features of LuaTeX. Lua includes all features required for OOP (see e.g. https://www.lua.org/pil/16.html https://www.lua.org/pil/16.html).
- WillAdams 3y agoYes, I was able to take advantage of this via lualatex to access METAPOST so as to do a parametric design for a CNC using OpenSCAD as a front-end: https://tug.org/TUGboat/tb40-2/tb125adams-3d.pdf https://tug.org/TUGboat/tb40-2/tb125adams-3d.pdf