Created
June 26, 2010 14:11
-
-
Save zc00gii/454077 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(defun pythagorean (a b) | |
"Find the 3rd line in a right angle. a^2 + b^2 = c^2 and a > c > b" | |
(declare (real a b)) | |
(if (> a b) 'f | |
(sqrt (+ (expt a 2) (expt b 2))))) | |
(defun reverse-pythagorean (c b) | |
"Reverse of `pythagorean' c^2 - b^2 = a^2 and c < b < a" | |
(declare (real b c)) | |
(if (> b c) 'f | |
(sqrt (- (expt c 2) (expt b 2))))) | |
(defun pythagoreanp (a b c) | |
"Returns t or nil if it's a correct pythagorean or not." | |
(declare (real a b c)) | |
(and (> a b) (> b c) = (pythagorean a b) c) (= (reverse-pythagorean c b) a)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment