Public Vars

Back

array (clj)

(source)

interface

(array size)

Examples

thheller/shadow-cljs
(ns shadow.remote.runtime.cljs.js-builtins
  (:require
    [goog.object :as gobj]
    [clojure.core.protocols :as p]))

  array
  (datafy [o]
    (vec o))
cognitect-labs/aws-api
(ns s3-examples
  (:require [clojure.core.async :as a]
            [clojure.spec.alpha :as s]
            [clojure.spec.gen.alpha :as gen]
            [clojure.java.io :as io]
            [clojure.repl :as repl]
            [cognitect.aws.client.api :as aws]))

  ;; Body is blob type, for which we accept a byte-array or an InputStream
  (aws/invoke s3 {:op :PutObject :request {:Bucket bucket-name :Key "hello.txt"
                                           :Body (.getBytes "Oh hai!")}})
mikera/core.matrix
(ns clojure.core.matrix.macros-clj
  "Namespace for core.matrix macros. Keeping them separate allows us to do conditional
  macros that can handle the differences between Clojure and Clojurescript."
  (:require [clojure.core.matrix.macros :refer [TODO c-for]])
  (:import [java.util Arrays]))

(defmacro native-array? [m]
  `(.isArray (.getClass ~m)))
mikera/core.matrix
   Indexes are intended to be used to specify elements, ranges or sub-arrays of core.matrix arrays.
   As such they can be considered as a 1D vector of integer values."
  (:require [clojure.core.matrix.protocols :as mp]
            [clojure.core.matrix.macros :refer [error]])
  (:import [clojure.lang IPersistentVector]))


(extend-protocol mp/PIndexImplementation
  (Class/forName "[J")
	  (index? [m]
      true)
	  (index-to-longs [m]
      m)
	  (index-to-ints [m]
      (int-array m))
	  (index-from-longs [m xs]
      xs)
	  (index-from-ints [m xs]
      (long-array xs))
	  (index-coerce [m a]
      (mp/index-to-longs a)))

(extend-protocol mp/PIndexImplementation
  (Class/forName "[I")
	  (index? [m]
      true)
	  (index-to-longs [m]
      (long-array m))
	  (index-to-ints [m]
      m)
	  (index-from-longs [m xs]
      (int-array xs))
	  (index-from-ints [m xs]
      xs)
	  (index-coerce [m a]
      (mp/index-to-ints a)))

(extend-protocol mp/PIndexImplementation
  IPersistentVector
	  (index? [m]
      (every? integer? m))
	  (index-to-longs [m]
      (long-array m))
	  (index-to-ints [m]
      (int-array m))
	  (index-from-longs [m xs]
      (vec xs))
	  (index-from-ints [m xs]
      (vec xs))
	  (index-coerce [m a]
      (cond
        (mp/index? a)
          (mp/persistent-vector-coerce a)
        (== 1 (long (mp/dimensionality a)))
          (vec (mp/index-to-longs a))
        :else
          (error "Can't make a 1D index from array of shape " (mp/get-shape a)))))
mikera/core.matrix
(ns clojure.core.matrix.macros-cljs
  "Namespace for core.matrix macros. Keeping them separate allows us to do conditional
  macros that can handle the differences between Clojure and Clojurescript."
  (:require [clojure.core.matrix.macros :refer [c-for TODO]]))

(defmacro native-array? [m]
  `(identical? js/Array (.-constructor ~m)))