about summary refs log blame commit diff stats
path: root/fe/parade.fe
blob: d52b43a2eb170cf37ff61a5aec4f77fadf51bd6b (plain) (tree)

































































                                                                                       
; 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")