Sha256: d2714adc6f84a5180092227ee6ab9325ee5e5989d6fdc0b60821af9bd0c0afb6

Contents?: true

Size: 503 Bytes

Versions: 123

Compression:

Stored size: 503 Bytes

Contents

(ns complex-numbers)

(defn real [[a _]] a)

(defn imaginary [[_ b]] b)

(defn abs [[a b]] (Math/sqrt (apply + (map #(Math/pow % 2) [a b]))))

(defn conjugate [[a b]] [a (- b)])

(defn add [[a b] [c d]] [(+ a c) (+ b d)])

(defn sub [[a b] [c d]] [(- a c) (- b d)])

(defn mul [[a b] [c d]] [(- (* a c) (* b d)) (+ (* a d) (* b c))])

(defn div [[a b] [c d]]
  (let [denominator (apply + (map #(Math/pow % 2) [c d]))]
    [(/ (+ (* a c) (* b d)) denominator)
     (/ (- (* b c) (* a d)) denominator)]))

Version data entries

123 entries across 123 versions & 1 rubygems

Version Path
trackler-2.2.1.139 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.138 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.137 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.136 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.135 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.134 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.133 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.132 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.131 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.130 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.129 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.128 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.127 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.126 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.125 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.124 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.123 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.122 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.121 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.120 tracks/clojure/exercises/complex-numbers/src/example.clj