Public Vars

Back

short-array (clj)

(source)

function

(short-array size-or-seq) (short-array size init-val-or-seq)
Creates an array of shorts

Examples

mikera/core.matrix
(ns clojure.core.matrix.test-arrays
  (:refer-clojure :exclude [vector?])
  (:require [clojure.core.matrix.compliance-tester :as compliance]
            [clojure.core.matrix :as m]
            ;[clojure.core.matrix.utils :refer :all]
            [clojure.test :refer [deftest testing is]]
            [clojure.core.matrix.macros :refer [array?]]))

(deftest compliance-tests
  (compliance/instance-test (int-array [1 2 3]))
  (compliance/instance-test (float-array [1 2 3]))
  (compliance/instance-test (long-array []))
  (compliance/instance-test (char-array [\a \b \c]))
  (compliance/instance-test (object-array [(double-array [1 2 3])]))
  (compliance/instance-test (object-array [(short-array (map short [1 2 3]))]))
  (compliance/instance-test (into-array (Class/forName "[D")
                                        [(double-array [1 2])
                                         (double-array [3 4])])))
uncomplicate/fluokitten
(ns uncomplicate.fluokitten.core-test
  (:use [uncomplicate.fluokitten algo jvm core test utils])
  (:use [midje.sweet :exclude [just]])
  (:require [clojure.string :as s]
            [clojure.core.reducers :as r]))

(fmap-keeps-type + (short-array [77 0 -39]) (short-array [88 -8 8]))

(monad-law2-right-identity (short-array [1 2 -33]))

(semigroup-op-associativity (short-array [1 2]) (short-array [3 4]) (short-array [5 6]))

(facts "How Foldable arrays work."
       (fold (double-array [1 2 3 4 5])) => 15.0
       (fold (long-array (range 999))) => 498501
       (fold (short-array [])) => 0
       (fold (int-array [1 2 3 4 5]))= > 15
       (fold (float-array [1 2 3 4 5])) => 15.0

       (fold + (double-array [1 2 3 4])) => 10.0
       (fold * (float-array [1 2 3 4])) => 24.0
       (fold + 0 (int-array [1 2 3]) (int-array [4 5 6])) => 21
       (fold * 1 (short-array [1 2 3]) (short-array [4 5 6])) => 315
       (fold * 2 (long-array [1 2 3]) (long-array [4 5 6]) (long-array [7 8 9])
             (long-array [1 2 1]) (long-array [3 2 1])) => (throws UnsupportedOperationException)
       (fold * 2 (double-array [1 2 3 4]) (double-array [4 5 6]) (double-array [7 8 9])
             (double-array [1 2 1]) (double-array [3 2 1])) => (throws UnsupportedOperationException)
typedclojure/typedclojure
(ns ^:no-doc typed.ann.clojure
  "Type annotations for the base Clojure distribution."
  #?(:cljs (:require-macros [typed.ann-macros.clojure :as macros]))
  (:require [clojure.core :as cc]
            [typed.clojure :as t]
            #?(:clj [typed.ann-macros.clojure :as macros])
            #?(:clj typed.ann.clojure.jvm) ;; jvm annotations
            #?(:clj clojure.core.typed))
  #?(:clj
     (:import (clojure.lang PersistentHashSet PersistentList
                            APersistentMap #_IPersistentCollection
                            #_ITransientSet
                            IRef)
              (java.util Comparator Collection))))

;array ctors
#?@(:cljs [] :default [
cc/boolean-array (t/IFn [(t/U t/Num (t/Seqable t/Bool)) :-> (Array boolean)]
                        [t/Num (t/U t/Bool (t/Seqable t/Bool)) :-> (Array boolean)])
cc/byte-array (t/IFn [(t/U t/Num (t/Seqable Byte)) :-> (Array byte)]
                     [t/Num (t/U Byte (t/Seqable Byte)) :-> (Array byte)])
cc/char-array (t/IFn [(t/U t/Num (t/Seqable Character)) :-> (Array char)]
                     [t/Num (t/U t/Num (t/Seqable Character)) :-> (Array char)])
cc/short-array (t/IFn [(t/U t/Num (t/Seqable Short)) :-> (Array short)]
                      [t/Num (t/U Short (t/Seqable Short)) :-> (Array short)])
cc/int-array (t/IFn [(t/U t/Num (t/Seqable t/Num)) :-> (Array int)]
                    [t/Num (t/U t/Num (t/Seqable t/Num)) :-> (Array int)])
cc/double-array (t/IFn [(t/U t/Num (t/Seqable t/Num)) :-> (Array double)]
                       [t/Num (t/U t/Num (t/Seqable t/Num)) :-> (Array double)])
])