You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
; 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)
The text was updated successfully, but these errors were encountered:
the above works, but if we store the result of Nest in x and try to rr with x, it hangs indefinitely
The text was updated successfully, but these errors were encountered: