Trigonometric functions: Difference between revisions
Content deleted Content added
→{{header|R}}: Added REBOL example. |
added Clojure |
||
Line 245: | Line 245: | ||
} |
} |
||
}</lang> |
}</lang> |
||
=={{header|Clojure}}== |
|||
{{trans|fortran}} |
|||
<lang lisp>(ns user |
|||
(:require [clojure.contrib.generic.math-functions :as generic])) |
|||
;(def pi Math/PI) |
|||
(def pi (* 4 (atan 1))) |
|||
(def dtor (/ pi 180)) |
|||
(def rtod (/ 180 pi)) |
|||
(def radians (/ pi 4)) |
|||
(def degrees 45) |
|||
(println (str (sin radians) " " (sin (* degrees dtor)))) |
|||
(println (str (cos radians) " " (cos (* degrees dtor)))) |
|||
(println (str (tan radians) " " (tan (* degrees dtor)))) |
|||
(println (str (asin (sin radians) ) " " (* (asin (sin (* degrees dtor))) rtod))) |
|||
(println (str (acos (cos radians) ) " " (* (acos (cos (* degrees dtor))) rtod))) |
|||
(println (str (atan (tan radians) ) " " (* (atan (tan (* degrees dtor))) rtod)))</lang> |
|||
Output: (matches that of Java) |
|||
0.7071067811865475 0.7071067811865475 |
|||
0.7071067811865476 0.7071067811865476 |
|||
0.9999999999999999 0.9999999999999999 |
|||
0.7853981633974482 44.99999999999999 |
|||
0.7853981633974483 45.0 |
|||
0.7853981633974483 45.0 |
|||
=={{header|Common Lisp}}== |
=={{header|Common Lisp}}== |