-
Notifications
You must be signed in to change notification settings - Fork 0
/
42minjoy.joy
37 lines (35 loc) · 922 Bytes
/
42minjoy.joy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
(* the JOY interpreter written in JOY *)
joy ==
[ [
(* PUSH DATA: *)
[ nothing ] (* type void *)
[ false ] (* Booleans *)
[ 'A ] (* characters *)
[ 0 ] (* numbers *)
[ [] ] (* lists *)
(* OPERATIONS: *)
[ pop pop pop ]
[ dup pop dup ]
[ swap pop swap ]
[ cons pop cons ]
[ uncons pop uncons ]
[ select pop opcase ]
[ * pop * ]
[ + pop + ]
[ - pop - ]
[ / pop / ]
[ and pop and ]
[ or pop or ]
[ not pop not ]
[ body pop body ]
[ put pop put ]
[ get pop get ]
(* COMBINATORS: *)
[ i pop [joy] cons i ]
[ dip pop [joy] cons dip ]
[ step pop [joy] cons step ]
(* DEFINED *)
[ joy body joy ] ]
opcase
i ]
step ;