The following functions that operate on trees should be recursive. Some useful functions that you may need are provided in the file Cons.java, and you will need some of your functions from the last assignment. This assignment may be done in Java or in Lisp.
(findpath 'a 'b) = null (findpath 'a 'a) = ("done") (findpath 'a '(a)) = ("first" "done") (findpath 'gold '(rocks gold (monster))) = ("rest" "first" "done")
(follow '("rest" "first" "done") '(rocks gold (monster))) = gold
(corresp 'light '((my eyes) (have seen (the light))) '((my ears) (have heard (the music)))) ==> music
(solve '(= f (* m a)) 'f) => (= f (* m a))
(solve '(= (* m a) f) 'f) => (= f (* m a))
(solve '(= x (- y z)) 'y) (solve '(= (- y x) z) 'y) ; first try: null (solve '(= (+ x z) y) 'y) ; second try: succeeds => (= y (+ x z))
Demonstrate that you can solve the following equations for any of their variables. These equations are defined in the file.
(= s (* 0.5 (* a (expt t 2)))) (= s (+ s0 (* v t))) (= a (/ f m)) (= v (* a t)) (= f (/ (* m v) t)) (= f (/ (* m (expt v 2)) r)) (= h (- h0 (* 4.94 (expt t 2)))) (= c (sqrt (+ (expt a 2) (expt b 2)))) (= v (* v0 (- 1 (exp (/ (- t) (* r c))))))
Define a function Double solveit(Cons equations, String var, Cons values) where equations is a list of equations, var is a variable whose value is desired, and values is an association list of variables with known values. Search the list equations to find an equation that relates exactly these variables. Solve the equation for the desired variable and evaluate the solved equation to find its value.
(solveit formulas 'm '((f 10.0) (a 2.0))) => 5.0Use the equations in formulas to solve the following problems: