X_eTaL documentation
Files
- macro library demos/stencil-macros/Stencil.xtlm: Stencils written as pictures: a macro library. A kernel is written as its numbers, row by row (3 x 3, 5 x 5, ...); when the program is expanded, the macro writes the arithmetic the kernel stands for, one term per number that is not 0: the array moved by that number's offset from the center (a rotation, so the edges wrap) times the number. A 0 writes nothing and a 1 writes no multiply, so the code does exactly the work the kernel asks for.
- library demos/xetal-pipes/stages/Pipes.xtl: Pipes: what every stage shares. A stage's input is one text, its lines each ending in a newline; l_ines numbers every character by the line it is on, so a stage chooses or reorders whole lines with a mask or a grade over those numbers, never a loop over lines.
- program demos/life-microscope/life-microscope.xtl: Conway's Life under the microscope: the whole rule is one line, u:l_ife, and every array it builds on the way is shown here, for a glider on a 6 by 6 board (the edges wrap around). Run it with "xetal run demos/life-microscope/life-microscope.xtl"; it prints the board, the nine shifted copies' shape, their sum, the next board, and the glider four generations on (moved one cell down and to the right). The live page draws these same arrays as it runs: https://softwarewrighter.github.io/X_eTaL-demos/life-microscope/
- program demos/mandelbrot/mandelbrot.xtl: The Mandelbrot set as arrays: every point c of a view iterated at once, z becoming z * z + c, counting the steps each point stays within 2 of the origin. X_eTaL has no complex numbers yet (an ask: see the demo's README Workarounds), so z and c are each two Float arrays, their real and imaginary parts. Run it with "xetal run demos/mandelbrot/mandelbrot.xtl"; it prints the shapes of c and of the stepped state, the set drawn with characters, and one point's orbit (its real parts, then its imaginary parts). The live page steps k and lets you click a point for its orbit: https://softwarewrighter.github.io/X_eTaL-demos/mandelbrot/
- program demos/julia/julia.xtl: Julia sets and the Mandelbrot set from one function, u:i_terate. Both iterate z becoming z * z + c and count the steps z stays within 2 of the origin. For the Mandelbrot set, c is the grid of points and z starts at 0; for a Julia set, z starts at the grid and c is one number, which scalar extension spreads over the whole grid: the step is written once and works both ways. X_eTaL has no complex numbers yet, so z and c are each a real and an imaginary part (see the demo's README Workarounds). Run it with "xetal run demos/julia/julia.xtl"; it prints the grid's shape, a Julia set (c = -0.8 + 0.156i) drawn with characters, and the Mandelbrot set from the same function. The live page lets you pick c on the Mandelbrot map and watch the Julia set change: https://softwarewrighter.github.io/X_eTaL-demos/julia/
- program demos/reaction-diffusion/reaction-diffusion.xtl: Reaction-diffusion (Gray-Scott): two chemicals U and V on a grid. U is fed in, V eats U to make more V (U + 2V -> 3V), V is removed, and both spread to their neighbors. Every step is a few array expressions over the whole grid: four shifted copies for the spreading, products for the reaction. The patterns (spots, mazes, coral) appear by themselves. Run it with "xetal run demos/reaction-diffusion/reaction-diffusion.xtl"; it prints the seeded grid's shape, a maze drawn with characters, and V's total (grown from the seed's 9.0). The live page runs it frame by frame and lets you click a cell for its neighbors and its update's arithmetic: https://softwarewrighter.github.io/X_eTaL-demos/reaction-diffusion/
- program demos/wave-tank/wave-tank.xtl: A wave tank: the wave equation on a grid. Each step, every cell moves towards the average of its neighbors, carrying momentum from the step before: next = 2 u - previous + c^2 * (neighbors - 4 u). Walls are a mask, a source shakes up and down, and waves spread, bend through slits and interfere, all as array expressions over the whole grid. Run it with "xetal run demos/wave-tank/wave-tank.xtl"; it prints the state's shape and the surface drawn with characters (crests, troughs, the wall). The live page picks the scene (a double slit, a lens, two sources, an open tank) and lets you click for ripples: https://softwarewrighter.github.io/X_eTaL-demos/wave-tank/
- program demos/ca-lab/ca-lab.xtl: A cellular automata lab. Every rule here is a lookup table: each cell's neighborhood becomes a number, by rotations and arithmetic over the whole array, and the number picks the cell's next state from the table (s_elect). Changing the rule is changing the table. Run it with "xetal run demos/ca-lab/ca-lab.xtl"; it prints Rule 30 and Rule 90 as sixteen-generation boards, Life, Brian's Brain and Wireworld, each drawn with characters. The live page lets you edit the table and the board, one and two dimensions each their own view: https://softwarewrighter.github.io/X_eTaL-demos/ca-lab/
- program demos/langtons-ant/langtons-ant.xtl: Langton's ant: on a white cell it turns right, on a black cell left; it flips the cell and steps forward. From two rules comes chaos, and then, after about 10000 steps, a "highway" the ant builds forever. Here the ant is arrays: its position is a mask with a single 1, its direction a number; no indexing, no loops, just whole-array steps. Run it with "xetal run demos/langtons-ant/langtons-ant.xtl"; it prints the state's shape, the board drawn with characters (black, white, the ant), and how many cells are black. The live page runs it frame by frame and pauses when the highway forms: https://softwarewrighter.github.io/X_eTaL-demos/langtons-ant/
- program demos/sandpile/sandpile.xtl: The abelian sandpile: drop grains on a grid; a cell with 4 or more grains topples, giving one to each of its four neighbors, and grains that fall off the edge are lost. Repeat until every cell has fewer than 4. The order of the topples does not matter (that is what abelian means), so every cell topples at once, as often as it can: one array expression a round. The stable pile is a fractal. Run it with "xetal run demos/sandpile/sandpile.xtl"; it prints whether the pile is stable, the grains left, the total topples, and the pile drawn with characters. The live page runs it round by round, colored by grains, and lets you drop more: https://softwarewrighter.github.io/X_eTaL-demos/sandpile/
- program demos/nbody/nbody.xtl: N-body gravity with no loops. Every pair of bodies at once: the displacements of all pairs form a cube (2 x N x N, built by broadcasting with t_able), the cube gives every pair's softened inverse-square pull, and one reduce over the second body sums the pulls into each body's acceleration. A kick-drift-kick (leapfrog) step moves them all. Run it with "xetal run demos/nbody/nbody.xtl"; it prints the cube's shape, its x plane, the starting accelerations, the state after 50 steps, and the total momentum (which stays 0). The live page has four presets (the figure-eight, a binary star, a collapsing cluster, a Kepler ellipse) and lets you click a body for its row of the cube: https://softwarewrighter.github.io/X_eTaL-demos/nbody/
- program demos/fourier-epicycles/fourier-epicycles.xtl: Fourier epicycles: any closed curve is a sum of circles turning at whole-number speeds. Its points z = x + i y go through a discrete Fourier transform, written as two matrix products with the cosines and sines of one outer product of angles; each frequency is a circle, and the circles, strongest first, chained end to end, trace the curve. A running sum along the chain gives, at once, the curve rebuilt from the first 1, 2, 3, ... circles. Run it with "xetal run demos/fourier-epicycles/fourier-epicycles.xtl"; it prints the strength of each frequency, the four strongest speeds, and the mean error rebuilt from 1, 2, 4, 8 and all 16 circles. The live page lets you pick or draw a curve and slides how many circles trace it: https://softwarewrighter.github.io/X_eTaL-demos/fourier-epicycles/
- program demos/image-pipeline/image-pipeline.xtl: An image pipeline as array programs: a picture built from masks, blurred, its edges found with the Sobel kernels, thresholded, and shrunk by max-pooling. Every 3 x 3 filter is the same two steps: the stack of the nine shifted copies of the image (its windows), then the kernel times the stack, summed. Run it with "xetal run demos/image-pipeline/image-pipeline.xtl"; it prints the windows' and the pooled map's shapes, then the picture, the edge strength, the edges and the pooled edges, each drawn with characters. The live page lets you edit the kernels and pick a picture, and click a pixel for its window times each kernel: https://softwarewrighter.github.io/X_eTaL-demos/image-pipeline/
- program demos/stencil-macros/stencil-macros.xtl: Stencils by macro: image kernels written as pictures of numbers, and a macro library of our own (Stencil.xtlm, beside this file) that turns each into rotation arithmetic when the program is expanded. A 0 in a kernel writes no code at all and a 1 no multiply, so blur, edges, sharpen, emboss and heat each cost exactly their nonzero numbers. Run it with "xetal run demos/stencil-macros/stencil-macros.xtl"; it prints the totals a kernel keeps (blur and heat move the picture's total without changing it, edges sum to 0), then the picture and each result drawn with characters. See what the program becomes: "xetal expand demos/stencil-macros/stencil-macros.xtl". The live page lets you edit a kernel and see its expansion: https://softwarewrighter.github.io/X_eTaL-demos/stencil-macros/
- program demos/xetal-pipes/xetal-pipes.xtl: Unix pipes in X_eTaL: the arrays inside the stages (stages/*.xtl), shown on sample.txt. A stage reads standard input as one text; here the same text comes from the file. Every character is numbered by its line, so choosing lines is a mask and reordering them a grade: no loop over lines anywhere. Run it with "xetal run demos/xetal-pipes/xetal-pipes.xtl"; it prints the first line's character-to-line numbers, the counts xetalwc would give, where "lazy" starts and which lines it is on (grep), the padded lines' shape and which lines uniq keeps, and each line's rank and the text sorted by it. No live page: command line only (see the stages, xetalcat and friends, in the demo's README).
- program demos/eigencube/eigencube.xtl: Eigencube: a Rubik's cube solved by linear algebra, a port of Steffen Smolka's eigencube.py (github.com/smolkaj/eigencube, MIT). Each of the 26 cubelets is the integer point c of {-1, 0, 1}^3 where it sits in the solved cube and carries a rotation matrix R: it sits now at R c. A quarter turn of the face with outward normal v moves the cubelets with v . (R c) > 0 by one matrix product. The model and the solver are the Eigencube library of X_eTaL-libraries (pinned in LIBRARIES_COMMIT, read from work/libraries by "just libraries"); this program scrambles a cube and solves it with it.
- library /Users/mike/github/softwarewrighter/X_eTaL-demos/work/libraries/libs/Eigencube/src/Eigencube.xtl: Eigencube: a Rubik's cube as rotation matrices, turned by matrix products and solved by search. A port of Steffen Smolka's eigencube.py (github.com/smolkaj/eigencube, MIT). Each of the 26 cubelets is the integer point c of {-1, 0, 1}^3 where it sits in the solved cube and carries a rotation matrix R: it sits now at R c. A quarter turn of the face with outward normal v moves the cubelets with v . (R c) > 0, multiplying R by one rotation matrix. A batch of cubes is one array, n by 26 by 3 by 3, so all twelve turns of every cube in a search are two matrix products. Import it with an alias of your choice: "ec:" u_se< "Eigencube". Put libs/Eigencube/src on XETAL_PATH ("just path"); the reference is libs/Eigencube/docs. Names with l: are exported; those under h: are private to this file.
Items
| name | kind | type |
|---|---|---|
| ᵐs̲tencil< | macro | Char -> Char -> Char |
| ʰs̲ide | function | Int -> Int -> Int |
| ʰt̲erms | function | Float -> Char -> Char |
| ʰt̲erm | function | Float -> Char -> Char |
| ʰc̲ols | function | Int -> Char -> Char |
| ʰr̲ows | function | Int -> Char -> Char |
| ʰn̲um | function | Float -> Char |
| end | value | Char |
| nl | value | Char |
| z | value | Char |
| ʰe̲nded | function | Truthy a => Char -> a |
| ʰr̲ead1 | function | Unit -> Char |
| ʰr̲eadn | function | Int -> Char |
| ʰr̲eadall | function | Int -> Char |
| ˡr̲ead | function | Unit -> Char |
| ˡo̲ut | function | Char -> Int |
| ˡl̲ines | function | (Num a, Truthy a) => Char -> a |
| ˡc̲ount | function | (Num a, Truthy a) => Char -> a |
| ˡk̲eep | function | Truthy a => a -> Char -> Char |
| ˡm̲atrix | function | Char -> Char |
| ᵘl̲ife | function | (Num a, Truthy a) => a -> a |
| b | value | Int |
| r | value | Int |
| s | value | Int |
| rows | value | Int |
| cols | value | Int |
| cx | value | Float |
| cy | value | Float |
| w | value | Float |
| k | value | Int |
| aspect | value | Float |
| ᵘc̲entred | function | Int -> Float |
| re | value | Float |
| im | value | Float |
| cr | value | Float |
| ci | value | Float |
| ᵘs̲tep | function | (Float, Float, Float) -> (Float, Float, Float) |
| %2 | value | Float |
| zr | value | Float |
| zi | value | Float |
| counts | value | Float |
| m2 | value | |
| cr0 | value | Float |
| ci0 | value | Float -> Float |
| ᵘo̲rbit | function | |
| rows | value | Int |
| cols | value | Int |
| cx | value | Float |
| cy | value | Float |
| w | value | Float |
| k | value | Int |
| aspect | value | Float |
| ᵘc̲entred | function | Int -> Float |
| re | value | Float |
| im | value | Float |
| grid | value | (Float, Float) |
| %1 | value | Float |
| gr | value | Float |
| gi | value | (Float, Float) -> (Float, Float) -> (Float, Float, Float) |
| ᵘi̲terate | function | |
| %5 | value | Float |
| jzr | value | Float |
| jzi | value | |
| julia | value | |
| %6 | value | Float |
| mzr | value | |
| n | value | Int |
| du | value | Float |
| dv | value | Float |
| f | value | Float |
| k | value | Float |
| steps | value | Int |
| ᵘp̲lane | function | a -> a |
| ᵘl̲ap | function | Float -> Float |
| ᵘs̲tep | function | Float -> Float |
| sq | value | Bool |
| seed | value | Float |
| s0 | value | Float |
| s | value | Float |
| v | value | Float |
| rows | value | Int |
| cols | value | Int |
| c2 | value | Float |
| amp | value | Float |
| omega | value | Float |
| steps | value | Int |
| col | value | Int |
| row | value | Int |
| edge | value | Int |
| damp | value | Float |
| slits | value | Bool |
| wall | value | Float |
| src | value | Float |
| ᵘl̲ap | function | Float -> Float |
| ᵘs̲tep | function | (Float, Float, Float) -> (Float, Float, Float) |
| u0 | value | Float |
| %2 | value | Float |
| u | value | Float |
| p | value | Float |
| t | value | |
| h | value | |
| ᵘb̲its | function | Int -> Int |
| ᵘr̲ow | function | a -> Int -> a |
| ᵘg̲row | function | Int -> Int -> Int |
| ᵘc̲ount | function | (Num a, Num b, Truthy b) => a -> b |
| ᵘl̲ook | function | a -> Int -> a |
| tbl | value | Int |
| r0 | value | Int |
| h | value | Int |
| tbl | value | Int |
| h | value | Int |
| life | value | Int |
| glider | value | Int |
| brain | value | Int |
| b0 | value | Int |
| wire | value | Int |
| w0 | value | Int |
| rows | value | Int |
| cols | value | Int |
| steps | value | Int |
| ᵘs̲tep | function | (Int, Int, Int) -> (Int, Int, Int) |
| row | value | Int |
| col | value | Int |
| b0 | value | Int |
| a0 | value | Int |
| %2 | value | Int |
| b | value | Int |
| a | value | Int |
| d | value | |
| side | value | Int |
| grains | value | Int |
| rounds | value | Int |
| row | value | Int |
| col | value | Int |
| edge | value | Int |
| inside | value | Int |
| ᵘt̲opple | function | Int -> Int |
| ᵘs̲table | function | (Num a, Num b, Truthy b) => a -> b |
| ᵘp̲lane | function | a -> a |
| ᵘs̲tep | function | Int -> Int |
| mid | value | Int |
| h0 | value | Int |
| h0 | value | Int |
| s | value | Int |
| h | value | Int |
| g | value | Float |
| eps2 | value | Float |
| dt | value | Float |
| m | value | Float |
| steps | value | Int |
| n | value | Int |
| mj | value | Float |
| ᵘp̲lane | function | a -> a |
| ᵘc̲ube | function | Num a => a -> a |
| ᵘp̲ull | function | Float -> Float |
| ᵘa̲cc | function | Float -> Float |
| ᵘs̲tep | function | Float -> Float |
| ᵘr̲ound | function | Float -> Float |
| p0 | value | Float |
| v0 | value | Float |
| s0 | value | Float |
| s | value | Float |
| x | value | Float |
| y | value | Float |
| n | value | Int |
| k | value | Float |
| A | value | Float |
| C | value | Float |
| S | value | Float |
| re | value | Float |
| im | value | Float |
| amp | value | Float |
| f | value | Float |
| order | value | Int |
| T | value | Float |
| zr | value | Float |
| zi | value | Float |
| vx | value | Float |
| vy | value | Float |
| cx | value | Float |
| cy | value | Float |
| dx | value | Float |
| dy | value | Float |
| err | value | Float |
| ᵘr̲ound | function | Float -> Float |
| rows | value | Int |
| cols | value | Int |
| row | value | Int |
| col | value | Int |
| disk | value | Bool |
| box | value | Bool |
| img | value | Float |
| blur | value | Float |
| kx | value | Float |
| ky | value | Float |
| thresh | value | Float |
| ᵘw̲indows | function | a -> a |
| ᵘf̲ilter | function | Num a => a -> a -> a |
| smooth | value | Float |
| gx | value | Float |
| gy | value | Float |
| mag | value | Float |
| edges | value | Float |
| pool | value | Float |
| ᵘd̲raw | function | Float -> Char |
| rows | value | Int |
| cols | value | Int |
| row | value | Int |
| col | value | Int |
| disk | value | Bool |
| box | value | Bool |
| img | value | Float |
| ᵘb̲lur | function | Num a => a -> Float |
| ᵘe̲dges | function | Num a => a -> a |
| ᵘs̲harpen | function | Num a => a -> a |
| ᵘe̲mboss | function | Num a => a -> a |
| ᵘh̲eat | function | Float -> Float |
| smooth | value | Float |
| edges | value | Float |
| sharp | value | Float |
| relief | value | Float |
| spot | value | Float |
| warm | value | Float |
| ᵘd̲raw | function | Float -> Char |
| t | value | Char |
| ln | value | Int |
| needle | value | Char |
| k | value | Int |
| tt | value | Char |
| starts | value | Bool |
| hits | value | Int |
| m | value | Char |
| differs | value | Int |
| rank | value | Int |
| sorted | value | Char |
| sc | value | Int |
| x | value | Int |
| %10 | value | Int |
| sol | value | Int |
| lens | value | Int |
| e | value | |
| pts | value | Int |
| C | value | Int |
| kind | value | Int |
| z | value | Int |
| I | value | Int |
| ˡsolved | value | Int |
| N | value | Int |
| ˡfaces | value | Char |
| V | value | Int |
| dir | value | Int |
| E | value | Int |
| Mf | value | Int |
| M | value | Int |
| ʰt̲urns | function | Int -> Int |
| ʰp̲os | function | Int -> Int |
| ʰc̲hildren | function | Int -> Int |
| ˡt̲urn | function | Int -> Int -> Int |
| ˡd̲o | function | Int -> Int -> Int |
| across | value | Int |
| down | value | Int |
| ˡs̲tickers | function | Int -> Int |
| ʰg̲row | function | Int -> Int |
| G | value | Int |
| Tm | value | Int |
| ʰo̲rient | function | Int -> Int |
| at | value | Int |
| layer | value | Int |
| ʰn̲ext | function | Int -> Int |
| ʰr̲elax | function | Num a => a -> a |
| ʰd̲istances | function | Num a => a -> a |
| colDev | value | Int |
| Dsolved | value | Int |
| ˡs̲olved? | function | Truthy a => Int -> a |
| posDev | value | Int |
| Dplace | value | Int |
| yellowDown | value | Int |
| sets | value | Int |
| ʰs̲pec | function | Num a => a -> a |
| ʰo̲f | function | Int -> Int -> Int |
| ʰr̲elevant | function | Truthy a => Int -> a |
| ʰp̲roject | function | Num a => a -> a -> a |
| ʰs̲core | function | Int -> Int -> Float |
| batch | value | Int |
| greed | value | Float |
| ˡi̲nverse | function | Int -> Int |
| ʰf̲ace | function | Int -> Int |
| ʰc̲ubes | function | Int -> Int |
| ʰk̲ey | function | Num a => a -> a |
| macros | value | Box Int |
| middle | value | Int |
| bottom | value | Int |
| ʰa̲ctions | function | (Num a, Num b) => a -> b -> Int |
| ʰa̲long | function | Int -> Int -> Int |
| ʰm̲acros | function | Int -> Int -> Int |
| ʰe̲xpand | function | Int -> Int -> Int |
| ʰf̲latten | function | Int -> Int |
| ʰs̲tep | function | Num a => (Int, Int) -> (Int, Int, Int, Int, a, Float, Int) -> Int |
| ʰt̲race | function | (Int, Int) -> Int -> Int |
| ʰs̲earch | function | (Int, Int) -> Int -> Int |
| ʰs̲tage | function | Num a => a -> (Int, Int, Int) -> (Int, Int, Int) |
| twist | value | Int |
| bottomTurn | value | Int |
| ʰo̲riented? | function | Int -> Int |
| ʰc̲orner | function | (Int, Int) -> (Int, Int) |
| ʰf̲inish | function | (Int, Int) -> (Int, Int) |
| ˡs̲olve | function | Num a => a -> Int -> (Int, Int, Int) |
| ˡn̲ame | function | Int -> Char |
| ˡp̲arse | function | Char -> Int |