0 Replies - 1085 Views - Last Post: 04 June 2010 - 02:01 PM

#1 Raynes  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 614
  • View blog
  • Posts: 2,815
  • Joined: 05-January 09

[Lisp] Pythagorean Theorem in Clojure

Posted 04 June 2010 - 02:01 PM

Description: Using A and B, you can get C. Or use C and B to get A. Translation of http://www.dreaminco...snippet5425.htm to Clojure
(defn ab [a b] (Math/sqrt (+ (Math/pow a 2) (Math/pow b 2))))

(defn bc [c b] (Math/sqrt (- (Math/pow c 2) (Math/pow b 2))))

(ab 5 7) ; C
(bc 20 15) ; A

Is This A Good Question/Topic? 0
  • +

Page 1 of 1