1.2.3-SNAPSHOT permalink Arrow_down_16x16
  • (minus & args)
Performs element-by-element subtraction on multiple matrices, sequences
and/or numbers. If only a single argument is provided, returns the
negative of the given matrix, sequence, or number. Equivalent to R's - operator.


Examples:

(def A (matrix [[1 2 3]
[4 5 6]
[7 8 9]]))
(minus A)
(minus A A A)
(minus A 2)
(minus 2 A)
(minus [1 2 3] [1 2 3])
(minus [1 2 3] 2)
(minus 2 [1 2 3])
(minus [1 2 3])

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source incanter/core.clj:423 top

(defn minus
"   Performs element-by-element subtraction on multiple matrices, sequences
    and/or numbers. If only a single argument is provided, returns the
    negative of the given matrix, sequence, or number. Equivalent to R's - operator.


    Examples:

      (def A (matrix [[1 2 3]
                      [4 5 6]
                      [7 8 9]]))
      (minus A)
      (minus A A A)
      (minus A 2)
      (minus 2 A)
      (minus [1 2 3] [1 2 3])
      (minus [1 2 3] 2)
      (minus 2 [1 2 3])
      (minus [1 2 3])

"
   ;([& args] (reduce (fn [A B] (combine-with A B clojure.core/- minus)) args)))
   ([& args] (if (= (count args) 1)
               (combine-with 0 (first args) clojure.core/- minus)
               (reduce (fn [A B] (combine-with A B clojure.core/- minus)) args))))
Vars in incanter.core/minus: = count defn first fn reduce -
Used in 0 other vars

Comments top

No comments for minus. Log in to add a comment.