Closed kwccoin closed 1 month ago
I wrote the lambda calculus interpreter quite a while ago. I've completely forgotten how it works. Could there be a bug? I'll look into it.
It doesn't seem like a bug. S, K, I, and Y are combinators. The corresponding lambda expressions are registered in advance. For example, when SKI is executed, it is reduced to a simple lambda expression. Y is a fixed-point combinator. Lambda calculus repeatedly performs substitution operations, applying them over and over until they can no longer be simplified. The interpreter shows this process.
L> SKI
(^x.^y.^z.xz(yz))(^x.^y.x)(^x.x)
(^x.^y.^z.xz(yz))(^x.^y.x)
^y.^z.(^x.^y.x)z(yz)
^z.(^x.^y.x)z(yz)
(^x.^y.x)z(yz)
(^x.^y.x)z
^y.z
^z.z
L>
Look like my newbie usage problem. Thought it is part of user interface. Need to learn how to “register in advance” and how. Can it be done in the interactive shell?
Assume not, as seen in the code in the lambda.lsp:
(defpattern combinator
((empty) nil)
((_x) (when (lambda-p _x)) _x)
((I) (parse* "^x.x"))
((K) (parse* "^x.^y.x"))
((S) (parse* "^x.^y.^z.xz(yz)"))
((Y) (parse* "^y.(^x.y(xx))(^x.y(xx))"))
(((_x :rest _xs)) (cons (combinator _x) (combinator _xs)))
((_x) _x))
unless one can safely change this definition?
defpattern is a unique extension feature of EISL. Generally, in Lisp, you use defun to register functions. You can input (defun foo (x) (+ x 1)) to the interpreter. As a result, the function foo will be registered. (foo 1) will return 2.
Try to follow the example of lambda
` % eisl Easy-ISLisp Ver5.35
Not sure why?