diff options
author | elioat <elioat@tilde.institute> | 2022-10-08 00:17:20 +0000 |
---|---|---|
committer | elioat <elioat@tilde.institute> | 2022-10-08 00:17:20 +0000 |
commit | edc101e80bfb932bba7a8c4f063e6b84a910c45b (patch) | |
tree | b5b27c7b485d3df945bc8505ad87cbf9ab11005f /fe | |
parent | 843db0701933f5899f9de17be409a4167f99b078 (diff) | |
download | tour-edc101e80bfb932bba7a8c4f063e6b84a910c45b.tar.gz |
*
Diffstat (limited to 'fe')
-rw-r--r-- | fe/parade.fe | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/fe/parade.fe b/fe/parade.fe new file mode 100644 index 0000000..d52b43a --- /dev/null +++ b/fe/parade.fe @@ -0,0 +1,66 @@ +; A simple game engine, based on https://wiki.xxiivv.com/site/parade.html +; Primitives: CREATE, PROGRAM, USE, LOOK +; DATA: the world is a stack. + +(= push + (mac (val lst) + (list '= lst (list 'cons val lst)))) + +(= for + (mac (item lst . body) + (list 'do + (list 'let 'for-iter lst) + (list 'while 'for-iter + (list 'let item '(car for-iter)) + '(= for-iter (cdr for-iter)) + (cons 'do body))))) + +(= create + (fn (new-obj) + (push (cons new-obj nil) world) + world)) + +(= put + (fn (to-put pair) + (do + (setcdr pair to-put) + pair))) + +(= program + (fn (target utility) + (for x world + (if (is (car x) target) (put utility x) + (not (car x) target) nil)))) + +(= all-of-creation + (fn (lst) + (print "> Behold, all of creation!") + (for x lst + (print "> " x)))) + +(= look + (fn (target) + (for x world + (if (is (car x) target) (print "> looking at" (car x) "reveals" (cdr x))) + (not (car x) target) nil))) + + + +(let world ()) +(create "banana") +(create "kiwi") +(create "apple") +(create "tango") +(program "apple" "bath") +(program "tango" "dance") +(program "kiwi" "shoe") +(program "banana" "peel") + +(all-of-creation world) + +(print "") + +(look "apple") +(look "tango") +(look "kiwi") +(look "banana") |