Print reduction steps

This commit is contained in:
Devine Lu Linvega 2024-04-01 19:26:29 -07:00
parent 8b79c3007b
commit 1655160113
3 changed files with 19 additions and 3 deletions

13
lisp.modal Normal file
View File

@ -0,0 +1,13 @@
define nil ()
define (pair (?x) (?y)) ((?x ?y))
define (first (?x ?y)) (?x)
define (second (?x ?y)) (?y)
define (quote ?x) (quote ?x)
define (if ?c ?t else ?f) (if/else ?c quote ?t quote ?f)
define (if/else (true) quote (?t) quote (?f)) (?t)
define (if/else (false) quote (?t) quote (?f)) (?f)
define (hello) (bye)
pair (pair (foo) (nil)) (baz)

View File

@ -305,7 +305,7 @@ def run(rules, queue, limit=pow(2, 32)):
result, queue = operation(queue, rules, pattern, *parameters) result, queue = operation(queue, rules, pattern, *parameters)
if result == True: if result == True:
failures = 0 failures = 0
#print("<>: ", inspect(seek(queue, ["SRT"]))) print("<>: ", inspect(seek(queue, ["SRT"])))
#print("<>: ", inspect(queue)) #print("<>: ", inspect(queue))
#input() #input()
steps = steps + 1 steps = steps + 1

View File

@ -1,4 +1,7 @@
define nil ((0)) define nil ((0))
define (cons ?x (?y)) ((?x ?y)) define (pair (?x) (?y)) ((?x ?y))
define (car (?x)) ?x define (first (?x ?y)) (?x)
define (second (?x ?y)) (?y)
define (quote ?x) (quote ?x)
define test (first pair (A) (pair (B) (pair (C) nil)))