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.119 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.118 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.117 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.116 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.115 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.114 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.113 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.111 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.110 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.109 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.108 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.107 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.106 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.105 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.104 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.103 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.102 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.101 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.100 tracks/clojure/exercises/complex-numbers/src/example.clj
trackler-2.2.1.99 tracks/clojure/exercises/complex-numbers/src/example.clj