diff --git a/src/tech/v3/datatype/functional.clj b/src/tech/v3/datatype/functional.clj index 223d5d33..ef5414c8 100644 --- a/src/tech/v3/datatype/functional.clj +++ b/src/tech/v3/datatype/functional.clj @@ -715,21 +715,61 @@ tech.v3.datatype.functional> (meta regressor) (defn reduce-* + "Invokes a reduce operation with the operand * to multiply items together. + + Examples: + + ```clojure + user> (dfn/reduce-* [1 2 3 4]) + 24 + user> (dfn/reduce-* [-1 1.1 4]) + -4.4 + ```" ([x] (tech.v3.datatype.functional-api/reduce-* x))) (defn reduce-+ + "Invokes a reduce operation with the operand + to add items together. + + Examples: + + ```clojure + user> (dfn/reduce-+ [1 2 3 4]) + 10 + user> (dfn/reduce-+ [-1 1.1 4]) + 4.1 + ```" ([x] (tech.v3.datatype.functional-api/reduce-+ x))) (defn reduce-max + "Invokes a reduce operation with the operand max find the maximum item of a list. + + Examples: + + ```clojure + user> (dfn/reduce-max [1 2 3 4]) + 4 + user> (dfn/reduce-max [10 -10 20 100 -1]) + 100 + ```" ([x] (tech.v3.datatype.functional-api/reduce-max x))) (defn reduce-min + "Invokes a reduce operation with the operand min find the minimum item of a list. + + Examples: + + ```clojure + user> (dfn/reduce-min [1 2 3 4]) + 1 + user> (dfn/reduce-min [10 -10 20 100 -1]) + -10 + ```" ([x] (tech.v3.datatype.functional-api/reduce-min x))) diff --git a/src/tech/v3/datatype/functional_api.clj b/src/tech/v3/datatype/functional_api.clj index 24ba1231..5faa546b 100644 --- a/src/tech/v3/datatype/functional_api.clj +++ b/src/tech/v3/datatype/functional_api.clj @@ -132,6 +132,16 @@ ;;Implement only reductions that we know we will use. (defn reduce-+ + "Invokes a reduce operation with the operand + to add items together. + + Examples: + + ```clojure + user> (dfn/reduce-+ [1 2 3 4]) + 10 + user> (dfn/reduce-+ [-1 1.1 4]) + 4.1 + ```" [x] ;;There is a fast path specifically for summations (dtype-reductions/commutative-binary-reduce @@ -139,18 +149,48 @@ (defn reduce-* + "Invokes a reduce operation with the operand * to multiply items together. + + Examples: + + ```clojure + user> (dfn/reduce-* [1 2 3 4]) + 24 + user> (dfn/reduce-* [-1 1.1 4]) + -4.4 + ```" [x] (dtype-reductions/commutative-binary-reduce (:tech.numerics/* binary-op/builtin-ops) x)) (defn reduce-max + "Invokes a reduce operation with the operand max find the maximum item of a list. + + Examples: + + ```clojure + user> (dfn/reduce-max [1 2 3 4]) + 4 + user> (dfn/reduce-max [10 -10 20 100 -1]) + 100 + ```" [x] (dtype-reductions/commutative-binary-reduce (:tech.numerics/max binary-op/builtin-ops) x)) (defn reduce-min + "Invokes a reduce operation with the operand min find the minimum item of a list. + + Examples: + + ```clojure + user> (dfn/reduce-min [1 2 3 4]) + 1 + user> (dfn/reduce-min [10 -10 20 100 -1]) + -10 + ```" [x] (dtype-reductions/commutative-binary-reduce (:tech.numerics/min binary-op/builtin-ops) x))