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.180 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.179 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.178 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.177 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.176 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.175 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.174 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.173 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.172 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.171 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.170 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.169 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.167 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.166 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.165 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.164 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.163 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.162 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.161 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.160 tracks/clojure/exercises/complex-numbers/src/example.clj