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.159 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.158 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.157 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.156 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.155 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.154 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.153 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.152 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.151 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.150 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.149 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.148 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.147 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.146 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.145 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.144 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.143 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.142 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.141 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.140 tracks/clojure/exercises/complex-numbers/src/example.clj