Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (define (check-arith)
- (let ((test1 2)
- (test2 '(cons '+
- (cons 2 (cons 3 null))))
- (test3 '(cons '+
- (cons (cons '- (cons 2 (cons 3 null)))
- (cons (cons '* (cons 2 (cons 3 null)))
- null))))
- (test4 '(cons '^
- (cons 2 (cons 3 null))))
- (test5 '(cons '/
- (cons (cons '+
- (cons (cons '- (cons 2 (cons 3 null)))
- (cons (cons '* (cons 2 (cons 3 null)))
- null)))
- (cons (cons '+
- (cons (cons '- (cons 3 (cons 1 null)))
- (cons (cons '* (cons 2 (cons 2 null)))
- null))) null)))))
- (list (eval (arith-eval test1)) ;; 2
- (eval (arith-eval test2)) ;; 5
- (eval (arith-eval test3)) ;; 5
- (eval (arith-eval test4)) ;; error:bad-operator
- (eval (arith-eval test5))))) ;; 5/6
- (check-arith)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement