Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readme example hangs when storing intermediate #6

Open
anandijain opened this issue Oct 20, 2023 · 0 comments
Open

readme example hangs when storing intermediate #6

anandijain opened this issue Oct 20, 2023 · 0 comments

Comments

@anandijain
Copy link
Owner

; Counting with Combinators
; First we define the sk rules
(set sk_rules (list (rule (((s (pattern x (blank))) (pattern y (blank))) (pattern z (blank))) ((x z) (y z))) (rule ((k (pattern x (blank))) (pattern y (blank))) x)))

; now we define the rule for incrementing
(set succ (s ((s (k s)) k)))

; now we apply succ to (s k) 10 times
(Nest succ (s k) 10)

; now we apply [s][k] to the result and do fixed-point replacement using our SK-rules
(rr (((Nest succ (s k) 10) s) k) sk_rules)
; you should see:
; (s (s (s (s (s (s (s (s (s (s k))))))))))

the above works, but if we store the result of Nest in x and try to rr with x, it hangs indefinitely

(set sk_rules (list (rule (((s (pattern x (blank))) (pattern y (blank))) (pattern z (blank))) ((x z) (y z))) (rule ((k (pattern x (blank))) (pattern y (blank))) x)))

(set succ (s ((s (k s)) k)))

(set x (Nest succ (s k) 10))

(rr ((x s) k) sk_rules)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant