Public Vars

Back

byte-array (clj)

(source)

function

(byte-array size-or-seq) (byte-array size init-val-or-seq)
Creates an array of bytes

Examples

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.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 zero-dimension-access
  (testing "Arrays are assumed to be scalars if accessed with zero dimensions"
    (is (m/equals [1] (m/mget (byte-array [1]))))
    (is (m/equals [1] (m/mget (double-array [1]))))))
hraberg/deuce
(ns deuce.emacs.character
  (:use [deuce.emacs-lisp :only (defun defvar)])
  (:require [clojure.core :as c])
  (:refer-clojure :exclude []))

(defun unibyte-string (&rest bytes)
  "Concatenate all the argument bytes and make the result a unibyte string."
  (String. (byte-array (map byte bytes)) "US-ASCII"))
cloojure/tupelo
;   Copyright (c) Alan Thompson. All rights reserved.
;   The use and distribution terms for this software are covered by the Eclipse Public License 1.0
;   (http://opensource.org/licenses/eclipse-1.0.php) which can be found in the file epl-v10.html at
;   the root of this distribution.  By using this software in any fashion, you are agreeing to be
;   bound by the terms of this license.  You must not remove this notice, or any other, from this
;   software.
(ns tst.tupelo.string
  (:refer-clojure :exclude [take drop])
  ;---------------------------------------------------------------------------------------------------
  ;   https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.html
  ;   http://blog.fikesfarm.com/posts/2015-12-18-clojurescript-macro-tower-and-loop.html
  #?(:cljs (:require-macros [tupelo.test]))
  (:require
    [clojure.test] ; sometimes this is required - not sure why
    [clojure.core :as cc]
    [tupelo.core :as t :refer [spy spyx spyxx spyx-pretty forv]]
    [tupelo.chars :as char]
    [tupelo.string :as str]
    [tupelo.test :refer [testing is verify verify-focus
                         is isnt is= isnt= is-set= is-nonblank= is-nonblank-lines=
                         throws? throws-not?
                         ]]
    ))

#?(:clj
   (do
     (verify
       (is (= [65 66 67] (vec (str/str->byte-array "ABC"))))
       (is (= "ABC" (str/byte-array->str (byte-array [65 66 67]))))
       (is (= "Hello World!" (-> "Hello World!" (str/str->byte-array) (str/byte-array->str))))

     (verify
       (is (= " :a :b 3 4" (t/seq->str [:a :b 3 4])))
       (is (= " \\a \\b \\c" (t/seq->str "abc")))
       (is (= " 1 2 3" (t/seq->str (byte-array [1 2 3])))))
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)])
])