├── test
├── ex
│ ├── 0.code
│ ├── 2.code
│ ├── 10.code
│ ├── 15.code
│ ├── 1.code
│ ├── 30.code
│ ├── 12.code
│ ├── 35.code
│ ├── 25.code
│ ├── 26.code
│ ├── 27.code
│ ├── 3.code
│ ├── 31.code
│ ├── 36.code
│ ├── 13.code
│ ├── 14.code
│ ├── 20.code
│ ├── 23.code
│ ├── 28.code
│ ├── 29.code
│ ├── 32.code
│ ├── 4.code
│ ├── 21.code
│ ├── 24.code
│ ├── 11.code
│ ├── 16.code
│ ├── 22.code
│ ├── 2450.code
│ ├── 33.code
│ ├── 103.code
│ ├── 230.code
│ ├── 42.code
│ ├── 90.code
│ ├── 233168.code
│ ├── 34.code
│ └── 100.code
├── componeer.code
├── index
├── doe.lua
├── stroom.lua
├── kogel.code
├── oplos.lua
├── exp.lua
├── defunc.lua
├── codegen.lua.1
├── pong.lua
├── langecode.lua
├── sb.code
├── incrementeel.lua
├── optimiseer.lua
├── luagen.lua
├── ontleed.lua
├── stress.lua
├── typeer.lua
└── bouw.lua
├── a.code
├── ex
├── wisk.code
├── dht.code
├── tmp
│ ├── bdec.code
│ ├── y.code
│ ├── e.code
│ ├── q.code
│ ├── z.code
│ ├── spel.code
│ ├── c.code
│ ├── p.code
│ ├── k.code
│ ├── w.code
│ ├── a.code
│ ├── bt.code
│ ├── d.code
│ ├── b.code
│ ├── x.code
│ └── s.code
├── spiderman.torrent
├── mooi.sh
├── fib.code
├── schaakstukken.code
├── priem.code
├── 27.5.code
├── func.code
├── animatie.code
├── geom.code
├── graaf.code
├── abc.code
├── landschap.code
├── kristal.code
├── leip.code
├── zen.code
├── icode.code
├── paint.code
├── oog.code
├── pe1.c
├── json.code
├── recursie.code
├── funkypaint.code
├── http.code
├── benc.code
├── kleur.code
├── klad
├── pe1.code
├── pe6.code
├── grafiek.code
├── midi.code
├── snake.code
├── slang.code
├── sb.code
├── kanaal.code
├── pe3.code
├── cirkels.code
├── mat.code
├── paint2.code
├── trippy.code
├── pe2.code
├── bdec.code
├── pe5.code
├── pe4.code
├── bdec1.code
├── b.code
├── cool1.code
├── screensaver.code
├── buis.code
├── kubus.code
├── set.lua
├── 3d.code
├── muziek.code
├── bencode.code
├── demo.code
├── pong.code
├── bdec1.exp.ansi
├── bieb.code
├── schaken2.code
├── ontleed.code
├── syntax.html
└── voer.code
├── lib
├── x75.code
├── lua.code
├── n.code
├── net.code
├── wisk.code
├── demo.code
├── geom.code
├── regels.code
├── demo.lst
├── unistd.code
├── 3d.code
├── geom.js.lst
├── x64.code
├── atomenjs.lst
├── std.code~Stashed changes
├── std.code~Stashed changes_0
├── std.code~Stashed changes_1
└── std2.code
├── web
├── www
│ ├── ex
│ │ ├── aap.code
│ │ ├── aap2.code
│ │ ├── aap3.code
│ │ ├── aap4.code
│ │ ├── aap5.code
│ │ ├── buis.code
│ │ ├── demo.code
│ │ ├── leip.code
│ │ ├── oog.code
│ │ ├── paint.code
│ │ ├── pe1.code
│ │ ├── pe2.code
│ │ ├── pe3.code
│ │ ├── pe4.code
│ │ ├── pe5.code
│ │ ├── pe6.code
│ │ ├── pong.code
│ │ ├── voer.code
│ │ ├── cirkels.code
│ │ ├── grafiek.code
│ │ ├── paint2.code
│ │ ├── schaken.code
│ │ ├── terrein.code
│ │ └── salvobal.code
│ ├── coord.png
│ ├── taal.png
│ ├── favicon.ico
│ ├── res
│ │ ├── crate.jpg
│ │ ├── dodo.png
│ │ ├── gras.png
│ │ ├── muur.png
│ │ ├── symf.mid
│ │ └── tetrisc.mid
│ ├── les
│ │ ├── 1.2-Waarde.code
│ │ ├── 2.2-Priemgetallen.code
│ │ ├── 1.1-Intro.code
│ │ ├── 1.3-Aanroepen.code
│ │ └── 1.4-Als-Dan.code
│ ├── nl.svg
│ ├── promo.html
│ ├── privacy.html
│ ├── en.svg
│ ├── lib
│ │ ├── slang.css
│ │ └── addon
│ │ │ └── selection
│ │ │ └── active-line.js
│ ├── gl.html
│ ├── id.svg
│ └── webgl.js
├── demoon
├── enc
└── a.code
├── .gdbinit
├── asm
├── hoi
├── mul
├── hoi.o
├── hoi0
├── hoi1
├── mul.o
├── vb
│ ├── vb
│ └── Makefile
├── win
│ ├── hoi.exe
│ ├── hoi0.exe
│ ├── hoi1.exe
│ ├── hoi2.exe
│ ├── win.exe
│ ├── hoi1.c
│ ├── hoi0.s
│ ├── hoi.s
│ ├── hoi1.s
│ ├── Makefile
│ └── win.c
├── abs.c
├── double.c
├── fib.c
├── win.s
├── a.c
├── comp.s
├── hoi.s
├── abs.s
├── call.s
├── hoi0.c
├── mul.s
├── double.s
├── fib.s
├── magnitude.s
├── Makefile
├── xcb.c
├── hoi0.s
└── xcb2.c
├── DEPS
├── socket
├── test.lua
├── Makefile
└── main.c
├── test.lua
├── parse
├── loc.h
├── Makefile
├── set.lua
├── lua.h
└── test.c
├── template.lua
├── .gitignore
├── translate.lua
├── template
├── doe
├── tolk
├── set.lua
├── hoi.lua
├── mmap.lua
├── getopt.lua
├── unicode.lua
├── byte.lua
├── Makefile
├── func.lua
├── README.md
├── symbol.lua
├── constoptm.lua
└── fout.lua
/test/ex/0.code:
--------------------------------------------------------------------------------
1 | main = 0
2 |
--------------------------------------------------------------------------------
/test/ex/2.code:
--------------------------------------------------------------------------------
1 | 2 = main
2 |
--------------------------------------------------------------------------------
/a.code:
--------------------------------------------------------------------------------
1 | out = grabbel [1,2,3]
2 |
--------------------------------------------------------------------------------
/test/ex/10.code:
--------------------------------------------------------------------------------
1 | main = 3 + 7
2 |
--------------------------------------------------------------------------------
/test/ex/15.code:
--------------------------------------------------------------------------------
1 | main = 15 ^ 1
2 |
--------------------------------------------------------------------------------
/test/ex/1.code:
--------------------------------------------------------------------------------
1 | x = 1
2 | main = x
3 |
--------------------------------------------------------------------------------
/test/ex/30.code:
--------------------------------------------------------------------------------
1 | main = (ja ⇒ 30)
2 |
--------------------------------------------------------------------------------
/ex/wisk.code:
--------------------------------------------------------------------------------
1 | ;hilbert-curve : curve
2 |
--------------------------------------------------------------------------------
/lib/x75.code:
--------------------------------------------------------------------------------
1 | (#) = X → uint8ptr (X-8)
2 |
--------------------------------------------------------------------------------
/test/ex/12.code:
--------------------------------------------------------------------------------
1 | x = -12
2 | main = - x
3 |
--------------------------------------------------------------------------------
/test/ex/35.code:
--------------------------------------------------------------------------------
1 | main = (2 > 1 ⇒ 35)
2 |
--------------------------------------------------------------------------------
/web/www/ex/aap.code:
--------------------------------------------------------------------------------
1 | ../../../ex/aap.code
--------------------------------------------------------------------------------
/web/www/ex/aap2.code:
--------------------------------------------------------------------------------
1 | ../../../ex/aap2.code
--------------------------------------------------------------------------------
/web/www/ex/aap3.code:
--------------------------------------------------------------------------------
1 | ../../../ex/aap3.code
--------------------------------------------------------------------------------
/web/www/ex/aap4.code:
--------------------------------------------------------------------------------
1 | ../../../ex/aap4.code
--------------------------------------------------------------------------------
/web/www/ex/aap5.code:
--------------------------------------------------------------------------------
1 | ../../../ex/aap5.code
--------------------------------------------------------------------------------
/web/www/ex/buis.code:
--------------------------------------------------------------------------------
1 | ../../../ex/buis.code
--------------------------------------------------------------------------------
/web/www/ex/demo.code:
--------------------------------------------------------------------------------
1 | ../../../ex/demo.code
--------------------------------------------------------------------------------
/web/www/ex/leip.code:
--------------------------------------------------------------------------------
1 | ../../../ex/leip.code
--------------------------------------------------------------------------------
/web/www/ex/oog.code:
--------------------------------------------------------------------------------
1 | ../../../ex/oog.code
--------------------------------------------------------------------------------
/web/www/ex/paint.code:
--------------------------------------------------------------------------------
1 | ../../../ex/paint.code
--------------------------------------------------------------------------------
/web/www/ex/pe1.code:
--------------------------------------------------------------------------------
1 | ../../../ex/pe1.code
--------------------------------------------------------------------------------
/web/www/ex/pe2.code:
--------------------------------------------------------------------------------
1 | ../../../ex/pe2.code
--------------------------------------------------------------------------------
/web/www/ex/pe3.code:
--------------------------------------------------------------------------------
1 | ../../../ex/pe3.code
--------------------------------------------------------------------------------
/web/www/ex/pe4.code:
--------------------------------------------------------------------------------
1 | ../../../ex/pe4.code
--------------------------------------------------------------------------------
/web/www/ex/pe5.code:
--------------------------------------------------------------------------------
1 | ../../../ex/pe5.code
--------------------------------------------------------------------------------
/web/www/ex/pe6.code:
--------------------------------------------------------------------------------
1 | ../../../ex/pe6.code
--------------------------------------------------------------------------------
/web/www/ex/pong.code:
--------------------------------------------------------------------------------
1 | ../../../ex/pong.code
--------------------------------------------------------------------------------
/web/www/ex/voer.code:
--------------------------------------------------------------------------------
1 | ../../../ex/voer.code
--------------------------------------------------------------------------------
/ex/dht.code:
--------------------------------------------------------------------------------
1 | id : int
2 | id : 0 .. 2^160
3 |
--------------------------------------------------------------------------------
/lib/lua.code:
--------------------------------------------------------------------------------
1 | app = stduitSchrijf(tekst(uit))
2 |
--------------------------------------------------------------------------------
/test/ex/25.code:
--------------------------------------------------------------------------------
1 | x = [0]^25
2 | main = #x
3 |
--------------------------------------------------------------------------------
/test/ex/26.code:
--------------------------------------------------------------------------------
1 | x = [3,4] ^ 13
2 | main = #x
3 |
--------------------------------------------------------------------------------
/test/ex/27.code:
--------------------------------------------------------------------------------
1 | x = 0..10
2 | main = 17 + #x
3 |
--------------------------------------------------------------------------------
/test/ex/3.code:
--------------------------------------------------------------------------------
1 | a = 3
2 | b = a
3 | main = b
4 |
--------------------------------------------------------------------------------
/test/ex/31.code:
--------------------------------------------------------------------------------
1 | main = (⇒)(nee, 100, 31)
2 |
--------------------------------------------------------------------------------
/test/ex/36.code:
--------------------------------------------------------------------------------
1 | main = (⇒)(2 < 1, 0, 36)
2 |
--------------------------------------------------------------------------------
/web/www/ex/cirkels.code:
--------------------------------------------------------------------------------
1 | ../../../ex/cirkels.code
--------------------------------------------------------------------------------
/web/www/ex/grafiek.code:
--------------------------------------------------------------------------------
1 | ../../../ex/grafiek.code
--------------------------------------------------------------------------------
/web/www/ex/paint2.code:
--------------------------------------------------------------------------------
1 | ../../../ex/paint2.code
--------------------------------------------------------------------------------
/web/www/ex/schaken.code:
--------------------------------------------------------------------------------
1 | ../../../ex/schaken.code
--------------------------------------------------------------------------------
/web/www/ex/terrein.code:
--------------------------------------------------------------------------------
1 | ../../../ex/terrein.code
--------------------------------------------------------------------------------
/test/ex/13.code:
--------------------------------------------------------------------------------
1 | x = 14
2 | y = 1
3 | main = x - y
4 |
--------------------------------------------------------------------------------
/test/ex/14.code:
--------------------------------------------------------------------------------
1 | x = 28
2 | y = 2
3 | main = x / y
4 |
--------------------------------------------------------------------------------
/test/ex/20.code:
--------------------------------------------------------------------------------
1 | x = [20, 30, 40]
2 | main = x₀
3 |
--------------------------------------------------------------------------------
/test/ex/23.code:
--------------------------------------------------------------------------------
1 | x = [1,2,3]
2 | main = 20 + #x
3 |
--------------------------------------------------------------------------------
/test/ex/28.code:
--------------------------------------------------------------------------------
1 | x = 10..20
2 | main = 18 + #x
3 |
--------------------------------------------------------------------------------
/test/ex/29.code:
--------------------------------------------------------------------------------
1 |
2 | x = -10 .. 19
3 | main = #x
4 |
--------------------------------------------------------------------------------
/web/demoon:
--------------------------------------------------------------------------------
1 | (cd /home/ymte/taal/web/ ; ./dienst)
2 |
--------------------------------------------------------------------------------
/web/www/ex/salvobal.code:
--------------------------------------------------------------------------------
1 | ../../../ex/salvobal.code
--------------------------------------------------------------------------------
/lib/n.code:
--------------------------------------------------------------------------------
1 | ;mainuit = uit
2 | main = in.vars → uit
3 |
--------------------------------------------------------------------------------
/test/ex/32.code:
--------------------------------------------------------------------------------
1 | als ja dan
2 | main = 32
3 | eind
4 |
--------------------------------------------------------------------------------
/test/ex/4.code:
--------------------------------------------------------------------------------
1 | main = x
2 | x = c
3 | x = a
4 | a = 4
5 |
--------------------------------------------------------------------------------
/.gdbinit:
--------------------------------------------------------------------------------
1 | layout regs
2 |
3 | set disassembly-flavor intel
4 |
--------------------------------------------------------------------------------
/lib/net.code:
--------------------------------------------------------------------------------
1 | lokale-gastheer = 0x7F000001
2 | elk-adres = 0
3 |
--------------------------------------------------------------------------------
/lib/wisk.code:
--------------------------------------------------------------------------------
1 | τ = 6.28318530717958647692528676655901
2 |
3 |
--------------------------------------------------------------------------------
/test/componeer.code:
--------------------------------------------------------------------------------
1 | f = x → x + 1
2 | g = y → y + 2
3 |
4 |
--------------------------------------------------------------------------------
/test/ex/21.code:
--------------------------------------------------------------------------------
1 | x = [20, 21, 22]
2 | y = 1
3 | main = x(y)
4 |
--------------------------------------------------------------------------------
/test/ex/24.code:
--------------------------------------------------------------------------------
1 | x = [1, 2, 3] || [4]
2 | main = #x + 20
3 |
--------------------------------------------------------------------------------
/asm/hoi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caminadab/metamine/HEAD/asm/hoi
--------------------------------------------------------------------------------
/asm/mul:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caminadab/metamine/HEAD/asm/mul
--------------------------------------------------------------------------------
/test/ex/11.code:
--------------------------------------------------------------------------------
1 | main = a + b + c
2 | a = 9
3 | b = 1
4 | c = 1
5 |
--------------------------------------------------------------------------------
/asm/hoi.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caminadab/metamine/HEAD/asm/hoi.o
--------------------------------------------------------------------------------
/asm/hoi0:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caminadab/metamine/HEAD/asm/hoi0
--------------------------------------------------------------------------------
/asm/hoi1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caminadab/metamine/HEAD/asm/hoi1
--------------------------------------------------------------------------------
/asm/mul.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caminadab/metamine/HEAD/asm/mul.o
--------------------------------------------------------------------------------
/asm/vb/vb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caminadab/metamine/HEAD/asm/vb/vb
--------------------------------------------------------------------------------
/ex/tmp/bdec.code:
--------------------------------------------------------------------------------
1 | bdec = data → waarde
2 | data₀ = 'i' ⇒ waarde =
3 |
--------------------------------------------------------------------------------
/test/ex/16.code:
--------------------------------------------------------------------------------
1 | main = z · x · y
2 | x = 2
3 | y = 2
4 | z = x · y
5 |
--------------------------------------------------------------------------------
/test/ex/22.code:
--------------------------------------------------------------------------------
1 | ; var index
2 | x = [1, 22, 23]
3 | main = x( x₀ )
4 |
--------------------------------------------------------------------------------
/DEPS:
--------------------------------------------------------------------------------
1 | sudo apt install gcc bison flex luajit liblua5.1-dev make lua-socket
2 |
--------------------------------------------------------------------------------
/ex/tmp/y.code:
--------------------------------------------------------------------------------
1 | h = "0123456789ABCDEF"
2 | a = h(-1)
3 | uit = [h₀, h₃, h₂]
4 |
--------------------------------------------------------------------------------
/test/ex/2450.code:
--------------------------------------------------------------------------------
1 | main = Σ (0..100) filter f
2 | f = X → (X mod 2 = 0)
3 |
--------------------------------------------------------------------------------
/test/ex/33.code:
--------------------------------------------------------------------------------
1 | als nee dan
2 | main = 100
3 | anders
4 | main = 33
5 | eind
6 |
--------------------------------------------------------------------------------
/asm/win/hoi.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caminadab/metamine/HEAD/asm/win/hoi.exe
--------------------------------------------------------------------------------
/asm/win/hoi0.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caminadab/metamine/HEAD/asm/win/hoi0.exe
--------------------------------------------------------------------------------
/asm/win/hoi1.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caminadab/metamine/HEAD/asm/win/hoi1.exe
--------------------------------------------------------------------------------
/asm/win/hoi2.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caminadab/metamine/HEAD/asm/win/hoi2.exe
--------------------------------------------------------------------------------
/asm/win/win.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caminadab/metamine/HEAD/asm/win/win.exe
--------------------------------------------------------------------------------
/web/www/coord.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caminadab/metamine/HEAD/web/www/coord.png
--------------------------------------------------------------------------------
/web/www/taal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caminadab/metamine/HEAD/web/www/taal.png
--------------------------------------------------------------------------------
/web/www/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caminadab/metamine/HEAD/web/www/favicon.ico
--------------------------------------------------------------------------------
/ex/spiderman.torrent:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caminadab/metamine/HEAD/ex/spiderman.torrent
--------------------------------------------------------------------------------
/test/ex/103.code:
--------------------------------------------------------------------------------
1 | main = 100 + f(0) + b + b + b + b
2 |
3 | b = 1/2
4 |
5 | f = x → b + b
6 |
--------------------------------------------------------------------------------
/test/ex/230.code:
--------------------------------------------------------------------------------
1 | l = (0..10) filter (x → x > 5) map (y → y²)
2 | main = reduceer(0, l, (+))
3 |
--------------------------------------------------------------------------------
/test/ex/42.code:
--------------------------------------------------------------------------------
1 | main = 40 + val₀ + val₁
2 | val = [(0,0),(1,1)] map (id ∘ (+))
3 | id = x → x
4 |
--------------------------------------------------------------------------------
/web/www/res/crate.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caminadab/metamine/HEAD/web/www/res/crate.jpg
--------------------------------------------------------------------------------
/web/www/res/dodo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caminadab/metamine/HEAD/web/www/res/dodo.png
--------------------------------------------------------------------------------
/web/www/res/gras.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caminadab/metamine/HEAD/web/www/res/gras.png
--------------------------------------------------------------------------------
/web/www/res/muur.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caminadab/metamine/HEAD/web/www/res/muur.png
--------------------------------------------------------------------------------
/web/www/res/symf.mid:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caminadab/metamine/HEAD/web/www/res/symf.mid
--------------------------------------------------------------------------------
/ex/mooi.sh:
--------------------------------------------------------------------------------
1 | vt -IBOKd a | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g" | pr -2 -w180 -e8
2 |
--------------------------------------------------------------------------------
/ex/tmp/e.code:
--------------------------------------------------------------------------------
1 | a : int
2 | a = 2.4
3 |
4 | b : (int, int)
5 | b = (2, 3, 4)
6 |
7 | uit = tekst a
8 |
--------------------------------------------------------------------------------
/test/index:
--------------------------------------------------------------------------------
1 | 0 nul
2 | 1 vars
3 | 10 arith
4 | 20 lijst
5 | 30 causatie
6 | 100 diversen
7 |
8 |
9 |
--------------------------------------------------------------------------------
/web/www/res/tetrisc.mid:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caminadab/metamine/HEAD/web/www/res/tetrisc.mid
--------------------------------------------------------------------------------
/test/ex/90.code:
--------------------------------------------------------------------------------
1 | lijst = (0..10) map verdubbel
2 | verdubbel = X → X · 2
3 | main = lijst vouw (+)
4 |
5 |
6 |
--------------------------------------------------------------------------------
/test/ex/233168.code:
--------------------------------------------------------------------------------
1 | multiple = i → ((i mod 3 = 0) of (i mod 5 = 0))
2 | main = Σ (1 .. 1000) filter multiple
3 |
4 |
--------------------------------------------------------------------------------
/test/ex/34.code:
--------------------------------------------------------------------------------
1 | als ja dan
2 | als nee dan
3 | main = 100
4 | anders
5 | main = 34
6 | eind
7 | eind
8 |
9 |
--------------------------------------------------------------------------------
/web/enc:
--------------------------------------------------------------------------------
1 | #!/usr/bin/lua
2 | require 'util'
3 | local pad = ...
4 | local data = lees(pad)
5 | print(escape(data))
6 |
--------------------------------------------------------------------------------
/ex/fib.code:
--------------------------------------------------------------------------------
1 | uit = "fib(20) = " || tekst(x) || [10]
2 | x = fib 20
3 | fib = n → (fⁿ[0,1]) 0
4 | f = [a,b] → [b,a+b]
5 |
--------------------------------------------------------------------------------
/ex/schaakstukken.code:
--------------------------------------------------------------------------------
1 | stukken = " ♜♞♝♛♚♝♞♜ ♟♟♟♟♟♟♟♟ ♙♙♙♙♙♙♙♙ ♖♘♗♕♔♗♘♖ "
2 | uit = teken [ label((5,5), stukken) ]
3 |
--------------------------------------------------------------------------------
/test/doe.lua:
--------------------------------------------------------------------------------
1 | require 'compile'
2 | require 'doe'
3 |
4 | local app = compile "uit = 1 + 2"
5 |
6 | --assert(doe(app) == 3)
7 |
--------------------------------------------------------------------------------
/web/www/les/1.2-Waarde.code:
--------------------------------------------------------------------------------
1 | ; Extra waarden definieer je met vergelijkingen:
2 | a = "hoi"
3 | b = a
4 | c = a
5 | uit = a
6 |
--------------------------------------------------------------------------------
/ex/priem.code:
--------------------------------------------------------------------------------
1 | ispriem = x → ⋀ bereik map rest
2 | bereik = 2 .. √(x + 1)
3 | rest = n → (x mod n ≠ 0)
4 |
5 | uit = ispriem ;(99999199999)
6 |
--------------------------------------------------------------------------------
/ex/27.5.code:
--------------------------------------------------------------------------------
1 | main = Σ (0..10) map k
2 | k = f ∘ g ∘ h ∘ i ∘ f ∘ g
3 | f = x → x + 1
4 | g = y → y / 2
5 | h = z → z · 2
6 | i = w → w - 1
7 |
--------------------------------------------------------------------------------
/ex/tmp/q.code:
--------------------------------------------------------------------------------
1 | ;a = {1, 2, 3} waarvoor sin
2 | f(a,b) = a + b
3 | A(ff,gg) = yy → ff(gg(yy))
4 | h = f A f
5 | c = h(2,3)
6 | uit = tekst(c)
7 |
8 |
--------------------------------------------------------------------------------
/asm/win/hoi1.c:
--------------------------------------------------------------------------------
1 | #include
" ‖ b)
7 | uit = "=== icode ===
" ‖ print(icode(v)) ; ‖ "
=== javascript === " ‖ tekst(v)
8 |
9 |
--------------------------------------------------------------------------------
/ex/paint.code:
--------------------------------------------------------------------------------
1 | ; paint
2 | circles := []
3 |
4 | if mouse.click then
5 | circles := circles ‖ [ circle(mouse.pos, 3) ]
6 | end
7 |
8 | if key.space then
9 | circles := []
10 | end
11 |
12 | out = draw circles
13 |
--------------------------------------------------------------------------------
/asm/vb/Makefile:
--------------------------------------------------------------------------------
1 | vb: main.c
2 | gcc -Wl,--build-id=none -Wa,--no-pad-sections -Wa,-R -Os main.c -lSDL2 -o vb
3 | objcopy --remove-section .comment vb
4 | objcopy --remove-section .eh_frame vb
5 | strip -S vb
6 | strip -s vb
7 |
--------------------------------------------------------------------------------
/ex/oog.code:
--------------------------------------------------------------------------------
1 | punten = ((0..1000) map f)
2 | f = i → (((looptijd · 10) mod scherm.breedte),50) + cossin(i/1000·τ+looptijd) · 30 · sin(i/10·looptijd)
3 | uit = teken [verf(polygoon(punten), rgb(.3,cos(looptijd·.7),sin looptijd))]
4 |
--------------------------------------------------------------------------------
/asm/double.c:
--------------------------------------------------------------------------------
1 | #include
uit[102,105,98,40,50,48,41,32,61,32] || tekst((_A -> ((_B -> [_B(1),_B(0) + _B(1)] ^ _A)([0,1]))(0))(20)) || [10] = "fib(20) = " || tekst(x)(_A -> ((_B -> [_B(1),_B(0) + _B(1)] ^ _A)([0,1]))(0))(20) || [10] 49 | x(_A -> ((_B -> [_B(1),_B(0) + _B(1)] ^ _A)([0,1]))(0))(20) = fib_A -> ((_B -> [_B(1),_B(0) + _B(1)] ^ _A)([0,1]))(0) 20 50 | fib_A -> ((_B -> [_B(1),_B(0) + _B(1)] ^ _A)([0,1]))(0) = n → (f_B -> [_B(1),_B(0) + _B(1)]ⁿ_A[0,1]) 0 51 | f_B -> [_B(1),_B(0) + _B(1)] = [a,b] → [b_B(1),a_B(0)+b_B(1)] 52 |53 | 54 | 55 | -------------------------------------------------------------------------------- /lib/std2.code: -------------------------------------------------------------------------------- 1 | ververs = moment → schrijf(tekst(uit)) 2 | app = herhaal.langzaam(ververs) 3 | 4 | ; canvas 5 | canvas = invoer.registreer(schrijf "") 6 | canvas.teken = canvas.wis ∘ (vormen2d vouw (∘)) 7 | canvas.render = vormen3d vouw (∘) 8 | 9 | ;video: nu → beeld 10 | ;schilder: canvas → canvas 11 | 12 | ;app = (video, audio, vars) 13 | ;in = (toets.neer, toets.op, nu, vars) 14 | 15 | context = canvas.context2d(schrijf "") 16 | ;teken = objs → (objs vouw (_)) context 17 | teken = obj → obj(context) 18 | 19 | ;rechthoek = ((x1,y1),(x2,y2)) → (ctx → (pad.begin ∘ pad.rect ∘ pad.eind)) 20 | 21 | ; verf: ctx → ctx 22 | 23 | ; schilder: obj → (canvas → canvas) 24 | ;render = vormen3d → (canvas.render(canvas.context3d(canvas)) ⇒ "") 25 | 26 | 27 | ; vec 28 | vec.plus = va,vb → va zip vb map (+) 29 | ;vec.min = va,vb → va zip (vb map (-)) map (+) 30 | vec.mul = va,vb → va zip vb map (·) 31 | vec.dot = vda,vdb → Σ (vda zip vdb map (·)) 32 | vec.schaal = vsv,vsf → vsv zip1 vsf map (·) 33 | 34 | ; vec4 35 | vec4.plus = vec.plus 36 | vec4.mul = vec.mul 37 | mat4.vmul = mvm,mvv → (mat4.transponeer mvm) zip1 mvv map vec.dot 38 | mat4.mul = mma,mmb → (mat4.transponeer mma) rzip1 mmb map mat4.vmul 39 | 40 | ; transformatie 41 | transform.verplaats = tva,tvb,tvc → ((1,0,0,0),(0,1,0,0),(0,0,1,0),(tva,tvb,tvc,1)) 42 | transform.schaal = tsx,tsy,tsz → ((tsx,0,0,0),(0,tsy,0,0),(0,0,tsz,0),(0,0,0,1)) 43 | 44 | ; [a b 0] [a 0 b] [1 0 0] 45 | ; [c d 0] [0 1 0] [0 a b] 46 | ; [0 0 1] [c 0 d] [0 c d] 47 | transform.xdraai = tdx → (1,0,0,0), (0, cos tdx, sin tdx, 0), (0, -sin tdx, cos tdx, 0), (0,0,0,1) 48 | transform.ydraai = tdy → (cos tdy, 0, sin tdy, 0), (0,1,0,0), (-sin tdy, 0, cos tdy, 0), (0,0,0,1) 49 | transform.zdraai = tdz → (cos tdz, sin tdz, 0, 0), (-sin tdz, cos tdz, 0, 0), (0,0,1,0), (0,0,0,1) 50 | transform.comp = mat4.mul 51 | 52 | ; scherm 53 | scherm.breedte = 177.778 54 | scherm.hoogte = 100 55 | ;scherm.frequentie = ? 56 | ;dt = scherm.frequentie 57 | 58 | ; mat4 59 | mat4.id = ((1,0,0,0),(0,1,0,0),(0,0,1,0),(0,0,0,1)) 60 | mat4.transponeer = mta,mtb,mtc,mtd → ((mta₀,mtb₀,mtc₀,mtd₀),(mta₁,mtb₁,mtc₁,mtd₁),(mta₂,mtb₂,mtc₂,mtd₂),(mta₃,mtb₃,mtc₃,mtd₃)) 61 | 62 | ; vec 63 | vec2.plus = (Va,Vb),(Vc,Vd) → Va+Vc, Vb+Vd 64 | vec2.mul = vec.mul 65 | vec2.schaal = (vx,vy),vf → (vx·vf,vy·vf) 66 | vec2.min = (px1,py1),(px2,py2) → px1-px2,py1-py2 67 | vec2.unit = sincos 68 | 69 | ; toetsenbord 70 | toets.spatie = toets.neer(32) 71 | toets.links = toets.neer(37) 72 | toets.omhoog = toets.neer(38) 73 | toets.rechts = toets.neer(39) 74 | toets.omlaag = toets.neer(40) 75 | toets.a = toets.neer(65) 76 | toets.w = toets.neer(87) 77 | toets.d = toets.neer(68) 78 | toets.s = toets.neer(83) 79 | 80 | toets.spatie.begin = toets.neer.begin(32) 81 | toets.links.begin = toets.neer.begin(37) 82 | toets.omhoog.begin = toets.neer.begin(38) 83 | toets.rechts.begin = toets.neer.begin(39) 84 | toets.omlaag.begin = toets.neer.begin(40) 85 | toets.a.begin = toets.neer.begin(97) 86 | toets.d.begin = toets.neer.begin(100) 87 | toets.s.begin = toets.neer.begin(115) 88 | toets.w.begin = toets.neer.begin(119) 89 | 90 | toets.spatie.eind = toets.neer.eind(32) 91 | toets.links.eind = toets.neer.eind(37) 92 | toets.omhoog.eind = toets.neer.eind(38) 93 | toets.rechts.eind = toets.neer.eind(39) 94 | toets.omlaag.eind = toets.neer.eind(40) 95 | toets.A.eind = toets.neer.eind(97) 96 | toets.D.eind = toets.neer.eind(100) 97 | toets.S.eind = toets.neer.eind(115) 98 | toets.W.eind = toets.neer.eind(119) 99 | -------------------------------------------------------------------------------- /constoptm.lua: -------------------------------------------------------------------------------- 1 | require 'util' 2 | require 'lib' 3 | local lib = lib() 4 | local makkelijk = set('+', '-', '·', '/', '%', '#', '_', '^', '√', '∧', '∨', 'Σ', '>', '<', '≥', '≤', '=', '≠', '⇒', '⊤', '⊥', '_l', '_t', '_t') 5 | local dynamic = set('looptijd', 'nu', 'starttijd', 'start', '∘', 6 | 'tcp.lees', 'tcp.schrijf', 'tcp.accepteer', 'tcp.bind', 7 | 'pad.begin', 'pad.eind', 'pad.rect', 'pad.vul', 'pad.verf', 8 | 'canvas.context', 'html', 9 | '_arg', 'schrijf', 'vierkant', 'cirkel', 'label', 'rechthoek', 'lijn', '_V', '_var', 'toets.neer', 'muis.klik', 'muis.klik.begin', 'muis.klik.eind', 'toets.neer.begin', 'toets.neer.eind', 'misschien', 'willekeurig', 'constant', 'id', 'merge', 'kruid') 10 | 11 | local function w2exp(w) 12 | local uit 13 | if w == true then 14 | uit = X'⊤' 15 | elseif w == false then 16 | uit = X'⊥' 17 | elseif w == nil then 18 | uit = X'niets' 19 | elseif type(w) == 'function' then 20 | -- functies kunnen we (nog) niet tot waarde maken 21 | assert(false) 22 | elseif w == 1/0 then 23 | uit = X('/', '1', '0') 24 | elseif tonumber(w) then 25 | uit = X(tostring(w)) 26 | elseif type(w) == 'string' then 27 | error'ok' 28 | elseif type(w) == 'table' then 29 | if w.isset then 30 | uit = X('{}', table.unpack(map(w, w2exp))) 31 | else 32 | uit = {} 33 | uit.o = X'[]' 34 | for i,v in ipairs(w) do 35 | uit[i] = w2exp(v) 36 | end 37 | end 38 | else 39 | uit = X(tostring(w)) 40 | end 41 | uit.w = w 42 | return uit 43 | end 44 | 45 | local function fname(exp) 46 | return isfn(exp) and fn(exp):sub(1,1) == '_' and atom(arg0(exp)) 47 | end 48 | 49 | 50 | function constoptm(exp) 51 | local constants = {} 52 | for exp in treepairsdfs(exp) do 53 | 54 | end 55 | end 56 | 57 | -- constanten vouwen 58 | function constoptm2(exp) 59 | -- literals 60 | if isatom(exp) then 61 | if tonumber(atom(exp)) then 62 | return exp, tonumber(atom(exp)) 63 | end 64 | if atom(exp) == "⊤" then return exp, true end 65 | if atom(exp) == "⊥" then return exp, false end 66 | if lib[atom(exp)] and not dynamic[atom(exp)] then 67 | if type(lib[atom(exp)]) ~= 'function' then 68 | return exp, lib[atom(exp)] 69 | else 70 | return nil, lib[atom(exp)] 71 | end 72 | end 73 | return exp, nil 74 | end 75 | 76 | -- string 77 | if obj(exp) == '"' then 78 | return exp, nil 79 | end 80 | 81 | 82 | -- objects 83 | if isobj(exp) then 84 | local nexp = {o=exp.o} 85 | local val = {} 86 | local isconstant = true 87 | for k, sub in subs(exp) do 88 | local sub, wsub = constoptm(sub) 89 | nexp[k] = sub 90 | if wsub then 91 | val[k] = wsub 92 | else 93 | isconstant = false 94 | end 95 | end 96 | assign(exp, nexp) 97 | nexp = exp 98 | if isconstant then 99 | return nexp, val 100 | else 101 | return nexp, nil 102 | end 103 | end 104 | 105 | 106 | -- operators 107 | if isfn(exp) then 108 | local narg,warg = constoptm(arg(exp)) 109 | 110 | local nexp, wexp 111 | if makkelijk[fn(exp)] and warg then 112 | if type(warg) == 'table' then 113 | wexp = lib[fn(exp)](warg[1], warg[2], warg[3], warg[4]) 114 | else 115 | wexp = lib[fn(exp)](warg) 116 | end 117 | nexp = w2exp(wexp) 118 | if nexp == nil then 119 | wexp = nil 120 | end 121 | elseif false then 122 | if fn(exp) == '_fn' then 123 | wexp = nil 124 | end 125 | --nexp = {f=exp.f, a=narg} --X(fn(exp), narg) 126 | --error(deparse(exp)) 127 | nexp = exp 128 | --wexp = nil 129 | end 130 | return nexp, wexp 131 | end 132 | return exp 133 | 134 | --assert(false) 135 | end 136 | -------------------------------------------------------------------------------- /test/bouw.lua: -------------------------------------------------------------------------------- 1 | do return end 2 | require 'build.assembleer' 3 | require 'build.link' 4 | require 'build.gen.asm' 5 | require 'build.gen.lua' 6 | require 'build.gen.js' 7 | require 'compile' 8 | require 'doe' 9 | 10 | function doelua(lua) 11 | return load(lua)() 12 | end 13 | 14 | function doeasm(asm) 15 | file('.test.s', asm) 16 | local elf = link(assembleer(asm, 'test')) 17 | file('.test.elf', elf) 18 | os.execute('chmod +x .test.elf') 19 | os.execute('./.test.elf ; echo $? > .test.out') 20 | local uit = file('.test.out') 21 | os.execute('rm .test.out') 22 | os.execute('rm .test.elf') 23 | local uit = uit:sub(1,#uit-1) 24 | return uit 25 | end 26 | 27 | function doejs(js) 28 | local src = "process.exit((function() {\n" .. js .. "\n})())" 29 | file('.test.js', src) 30 | os.execute('node .test.js ; echo $? > .test.out') 31 | local uit = file('.test.out') 32 | os.execute('rm .test.out') 33 | local uit = uit:sub(1,#uit-1) 34 | return uit 35 | end 36 | 37 | function test(code, moetzijn) 38 | -- niet optimaliseren aub 39 | opt = {['0'] = false} 40 | local im,fouten = compile(code) 41 | assert(im, "oncompilebaar: "..code) 42 | 43 | local js = jsgen(im) 44 | local asm = asmgen(im) 45 | 46 | 47 | local imval = tostring(doe(im)) 48 | local asmval = tostring(doeasm(asm)) 49 | local jsval = tostring(doejs(js)) 50 | 51 | if imval ~= asmval or imval ~= jsval then 52 | print(code) 53 | print('Im', 'Js', 'Asm') 54 | print(imval, jsval, asmval) 55 | print() 56 | 57 | 58 | print('# Im') 59 | for i,ins in ipairs(im) do 60 | print(unlisp(ins)) 61 | end 62 | print() 63 | 64 | if imval ~= jsval then 65 | print('# Javascript') 66 | print(js) 67 | print() 68 | end 69 | if imval ~= asmval then 70 | print('# Assembly') 71 | print(asm:sub(1,100)) 72 | print() 73 | end 74 | 75 | --assert(false) 76 | end 77 | 78 | end 79 | 80 | -- arit 81 | test("main = 2", 2) 82 | test("main = 1 + 2", 3) 83 | test("main = 1 + 2 · 3", 7) 84 | test("main = 6 - 2", 4) 85 | 86 | -- functioneel 87 | test("f = x → x + 1\nmain = f(1)", 2) 88 | test("f = x → x + 1\nmain = (f ∘ f)(1)", 3) 89 | test("f = x → x + 1\nmain = (f ^ 3)(1)", 4) 90 | 91 | -- logica 92 | test("main = (ja ⇒ 2)", 2) 93 | 94 | 95 | test([[ 96 | f = x → x + 10 97 | g = y → y + 100 98 | h = (f ∘ g)³ 99 | main = h(3)]], 100 | 333) 101 | test("main = (x → x + 1)(2)", 3) 102 | test("main = [1,2,3] vouw (+)", 6) 103 | test([[ 104 | f = x,y → y,x 105 | a = f(2, 3) 106 | main = a₀ 107 | ]], 3) 108 | 109 | test([[ 110 | sgn = x → y 111 | 112 | als x < 0 dan 113 | y = -1 114 | anders 115 | y = 1 116 | end 117 | 118 | main = sgn 3 119 | ]], 1) 120 | 121 | test('main = -3' --[[ 122 | main = itoa(atoi(itoa(atoi(itoa(atoi(itoa(-3))))))) 123 | 124 | ; text -> integer 125 | atoi = b → i 126 | ; negatief? 127 | als b₀ = '-' dan 128 | sign = -1 129 | tekens = b vanaf 1 130 | anders 131 | sign = 1 132 | tekens = b 133 | eind 134 | 135 | ; cijfers van de text 136 | cijfers = tekens map (t → t - '0') 137 | cijfers = tekens zip1 ('0') map (-) 138 | 139 | ; waarde van elk cijfer gegeven de positie 140 | waarde = (k → cijfers(j) · 10^k) 141 | j = #tekens - k - 1 142 | 143 | ; positie en resultaat 144 | pos = 0 .. #tekens 145 | i = sign · Σ (pos map waarde) 146 | 147 | ; integer -> text 148 | itoa = x → a 149 | n = 1 + ⌊log10(max(abs x, 1))⌋ 150 | als x < 0 dan 151 | neg = "-" 152 | anders 153 | neg = "" 154 | eind 155 | a = neg ‖ ((n .. 0) map cijfer) 156 | geschaald = (abs x)/10^m 157 | cijfer = m → '0' + ⌊geschaald mod 10⌋ 158 | ]], -3) 159 | 160 | print('alles ok') 161 | -------------------------------------------------------------------------------- /socket/main.c: -------------------------------------------------------------------------------- 1 | #define _POSIX_C_SOURCE 199309L 2 | #ifdef _WIN32 //defined(_MSC_VER) 3 | #define EXPORT __declspec(dllexport) 4 | #define IMPORT __declspec(dllimport) 5 | #elif defined(__GNUC__) 6 | #define EXPORT __attribute__((visibility("default"))) 7 | #define IMPORT 8 | #else 9 | #define EXPORT 10 | #define IMPORT 11 | #pragma warning Hoe te exporteren? 12 | #endif 13 | 14 | 15 | #include