Created
July 24, 2009 20:49
-
-
Save fffej/154542 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn isolate | |
"Isolate the lone x in e on the left-hand side of e" | |
[e x] | |
(dbg :student (format "e=%s x=%s" e x)) | |
(cond | |
;; X = A ==> X = n | |
(= (:lhs e) x) e | |
;; A = f(X) ==> f(X) = A | |
(in-exp x (:rhs e)) (isolate (mk-exp (:rhs e) '= (:lhs e)) x) | |
;; f(X) * A = B ==> f(X) = B / A | |
(in-exp x (:lhs (:lhs e))) (isolate (mk-exp (:lhs (:lhs e)) | |
'= | |
(mk-exp (:rhs e) | |
(inverse-op (:op (:lhs e))) | |
(:rhs (:lhs e)))) | |
x) | |
;; A * f(X) = B ==> f(x) = B / A | |
(commutative? (:op (:lhs e))) (isolate (mk-exp (:rhs (:lhs e)) | |
'= | |
(mk-exp (:rhs e) | |
(inverse-op (:op (:lhs e))) | |
(:lhs (:lhs e)))) | |
x) | |
;; A / f(X) = B ==> f(x) = A / B | |
:else (isolate (mk-exp (:rhs (:lhs e)) | |
'= | |
(mk-exp (:lhs (:lhs e)) | |
(:op (:lhs e)) | |
(:rhs e))) | |
x))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment