Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defun make-exp (x op y)
- (funcall op x y))
- (defun eek (exp)
- (cond ((null (second exp)) exp)
- ((and (listp (first exp)) (listp (third exp)))
- (make-exp (eek (first exp)) (second exp) (eek (third exp))))
- ((listp (first exp)) (make-exp (eek (first exp)) (second exp) (third exp)))
- ((listp (third exp)) (make-exp (first exp) (second exp) (eek (third exp))))
- (t (make-exp (first exp) (second exp) (third exp)))))
- (defun listify (exp)
- (if (endp (cdr exp))
- (car exp)
- (list (car exp) (cadr exp) (listify (cddr exp)))))
- (defun listify-2 (exp)
- (cond ((endp (cdr exp)) (car exp))
- ((listp (car exp)) (list (listify-2 (car exp)) (cadr exp) (listify-2 (cddr exp))))
- (t (list (car exp) (cadr exp) (listify-2 (cddr exp))))))
- (defun naive-infix (exp)
- (let ((listified (listify-2 exp)))
- (print listified)
- (eek listified)))
- (naive-infix '(1 + (2 * (12 / 3) + 6) - 4))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement