Public Vars

Back

hash (clj)

(source)

function

(hash x)
Returns the hash code of its argument. Note this is the hash code consistent with =, and thus is different than .hashCode for Integer, Short, Byte and Clojure collections.

Examples

hraberg/deuce
(ns deuce.emacs.ccl
  (:use [deuce.emacs-lisp :only (defun defvar)])
  (:require [clojure.core :as c])
  (:refer-clojure :exclude []))

(defvar translation-hash-table-vector nil
  "Vector containing all translation hash tables ever defined.
  Comprises pairs (SYMBOL . TABLE) where SYMBOL and TABLE were set up by calls
  to `define-translation-hash-table'.  The vector is indexed by the table id
  used by CCL.")
hraberg/deuce
(ns deuce.emacs.alloc
  (:use [deuce.emacs-lisp :only (defun defvar) :as el]
        [taoensso.timbre :as timbre
         :only (trace debug info warn error fatal spy)])
  (:require [clojure.core :as c]
            [clojure.walk :as w]
            [deuce.emacs-lisp.cons :as cons])
  (:refer-clojure :exclude [vector cons list])
  (:import [java.util Arrays]
           [java.lang.management ManagementFactory MemoryNotificationInfo MemoryType MemoryPoolMXBean]
           [javax.management NotificationListener NotificationEmitter Notification]))

(defvar purify-flag nil
  "Non-nil means loading Lisp code in order to dump an executable.
  This means that certain objects should be allocated in shared (pure) space.
  It can also be set to a hash-table, in which case this table is used to
  do hash-consing of the objects allocated to pure space.")
mhuebert/maria
(ns cells.cell
  (:refer-clojure :exclude [bound-fn get])
  (:require [clojure.core :as core]
            [cells.util :as util]
            [applied-science.js-interop :as j]))

(defmacro cell
  "Returns an anonymous cell. Only one cell will be returned per lexical instance of `cell`,
  unless a unique `key` is provided. `self` is brought into scope, referring to the current cell."
  ([expr]
   `(~'cells.cell/cell nil ~expr))
  ([key expr]
   (let [id (util/unique-id)]
     `(~'cells.cell/cell*
       (fn [~'self] ~expr)
       (str ~id "#" (hash ~key))))))
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))))

#?(:cljs (do
(t/ann-protocol cljs.core/Fn)
(t/ann-protocol cljs.core/IFn)
(t/ann-protocol cljs.core/ICloneable
                -clone [cljs.core/ICloneable :-> t/Any])
(t/ann-protocol [[x :variance :covariant]]
                cljs.core/IIterable
                ;; TODO
                -iterator [(cljs.core/IIterable x) :-> t/Any #_Object])
(t/ann-protocol cljs.core/ICounted
                -count [cljs.core/ICounted :-> t/Num])
(t/ann-protocol cljs.core/IEmptyableCollection
                ;; :/ TFn param on protocol?
                -empty [cljs.core/IEmptyableCollection :-> t/Any])
(t/ann-protocol cljs.core/ICollection
                -conj [cljs.core/ICollection t/Any :-> cljs.core/ICollection])
(t/ann-protocol [[x :variance :covariant]] cljs.core/IIndexed
                -nth (t/All [y]
                            [(cljs.core/IIndexed x) t/JSnumber (t/? y) :-> (t/U x y)]))
(t/ann-protocol cljs.core/ASeq)
(t/ann-protocol [[x :variance :covariant
                  ;;FIXME causes mystery error
                  ;:< t/AnyNilableNonEmptySeq
                  ]]
                cljs.core/ISeqable)
(t/ann-protocol [[x :variance :covariant]] cljs.core/ISeq
                -first [(cljs.core/ISeq x) :-> (t/Nilable x)]
                -rest [(cljs.core/ISeq x) :-> (cljs.core/ISeq x)])
;cljs.core/INext [[x :variance :covariant]]
(t/ann-protocol [[v :variance :covariant]] cljs.core/ILookup)
(t/ann-protocol [[k :variance :covariant]
                 [v :variance :covariant]]
                cljs.core/IAssociative
                -contains-key [(cljs.core/IAssociative k v) t/Any :-> t/Bool]
                -assoc (t/All [k1 v1] [(cljs.core/IAssociative k v) k1 v1 :->
                                       (cljs.core/IAssociative (t/U k k1) (t/U v v1))]))
(t/ann-protocol cljs.core/IMap
                -dissoc [cljs.core/IMap t/Any :-> cljs.core/IMap])
(t/ann-protocol [[k :variance :covariant]
                 [v :variance :covariant]]
                cljs.core/IMapEntry
                -key [(cljs.core/IMapEntry k v) :-> k]
                -val [(cljs.core/IMapEntry k v) :-> v])
(t/ann-protocol cljs.core/ISet
                -disjoin (t/All [s] [s t/Any :-> s]))
(t/ann-protocol [[x :variance :covariant]]
                cljs.core/IStack
                -peek [(cljs.core/IStack x) :-> (t/U nil x)]
                -pop [(cljs.core/IStack x) :-> (cljs.core/IStack x)])
(t/ann-protocol [[x :variance :covariant]]
                cljs.core/IVector
                -assoc-n (t/All [x1] [(cljs.core/IVector x) t/Num x1
                                      :-> (cljs.core/IVector (t/U x x1))]))
(t/ann-protocol [[x :variance :covariant]]
                cljs.core/IDeref
                -deref [(cljs.core/IDeref x) :-> x])
(t/ann-protocol [[x :variance :covariant]]
                cljs.core/IDerefWithTimeout
                -deref-with-timeout [(cljs.core/IDerefWithTimeout x) :-> x])
(t/ann-protocol cljs.core/IMeta
                -meta [cljs.core/IMeta :-> (t/Nilable (t/Map t/Any t/Any))])
(t/ann-protocol cljs.core/IWithMeta
                -with-meta [cljs.core/IWithMeta (t/Nilable (t/Map t/Any t/Any)) :-> cljs.core/IWithMeta])
;TODO
;cljs.core/IReduce [[]]
(t/ann-protocol cljs.core/IKVReduce ;;TODO
                -kv-reduce [cljs.core/IKVReduce [t/Any t/Any t/Any :-> t/Any] :-> t/Any])
(t/ann-protocol cljs.core/IList)
(t/ann-protocol cljs.core/IEquiv
                -equiv [cljs.core/IEquiv t/Any :-> t/Bool])
(t/ann-protocol cljs.core/IHash
                -hash [cljs.core/IHash :-> t/Num])
(t/ann-protocol cljs.core/ISequential)
(t/ann-protocol cljs.core/IRecord)
(t/ann-protocol [[x :variance :covariant]]
                cljs.core/IReversible
                -rseq [(cljs.core/IReversible x) :-> (t/NilableNonEmptySeq x)])
(t/ann-protocol [[k :variance :covariant]
                 [v :variance :covariant]] cljs.core/IFind
                -find [(cljs.core/IFind k v) t/Any :-> (t/Nilable (cljs.core/IMapEntry k v))]
                )
(t/ann-protocol [[x :variance :invariant]]
                cljs.core/ISorted
                -sorted-seq [(cljs.core/ISorted x) t/Bool :-> (t/Nilable (t/ASeq x))]
                ;; second arg => comparable?
                -sorted-seq-from [(cljs.core/ISorted x) t/Any t/Bool :-> (t/Nilable (t/ASeq x))]
                -entry-key [(cljs.core/ISorted x) t/Any :-> t/Any]
                -comparator [(cljs.core/ISorted x) :-> [x x :-> t/Num]])
(t/ann-protocol cljs.core/IPending)
;cljs.core/IWriter [[]]
;cljs.core/IPrintWithWriter [[]]
;    ;TODO
;;cljs.core/IWatchable [[]]
;    ;cljs.core/IEditableCollection [[]]
;    ;cljs.core/ITransientCollection [[]]
;    ;cljs.core/ITransientAssociative [[]]
;    ;cljs.core/ITransientMap [[]]
;    ;cljs.core/ITransientVector [[]]
;    ;cljs.core/ITransientSet [[]]
(t/ann-protocol [[x :variance :invariant]]
                cljs.core/IComparable)
;    ;cljs.core/IChunk [[]]
;    ;cljs.core/IChunkedSeq [[]]
;    ;cljs.core/IChunkedNext [[]]
(t/ann-protocol cljs.core/INamed
                -named [cljs.core/INamed :-> t/Str]
                -namespace [cljs.core/INamed :-> (t/Nilable t/Str)])
(t/ann-protocol [[x :variance :invariant]]
                cljs.core/IVolatile
                -vreset! (t/All [x] [(cljs.core/IVolatile x) x :-> x]))

cc/set (t/All [x] [(t/Seqable x) :-> #?(:cljs (t/Set x)
                                        :default (PersistentHashSet x))])
cc/hash-set (t/All [x] [x :* :-> #?(:cljs (t/Set x)
                                    :default (PersistentHashSet x))])
;TODO
;cc/hash-map (t/All [x y z :..]
;                   (t/IFn [(t/cat z z) :.. z :-> (t/Assoc '{} z :.. z)]
;                          [(t/cat x y) :* :-> (t/Map x y)]))
cc/hash-map (t/All [x y] [(t/cat x y) :* :-> (t/Map x y)])
cc/array-map (t/All [x y] [(t/cat x y) :* :-> (t/Map x y)])
cc/sorted-map (t/All [x y] [(t/cat x y) :* :-> (t/SortedMap x y)])
cc/sorted-map-by (t/All [x y] [[x x :-> t/Int] (t/cat x y) :* :-> (t/SortedMap x y)])
cc/sorted-set (t/All [x] [x :* :-> (t/SortedSet x)])
;;FIXME use t/Comparator for first arg
cc/sorted-set-by (t/All [x] [[x x :-> t/Int] x :* :-> (t/SortedSet x)])
cc/list (t/All [x] [x :* :-> (#?(:clj PersistentList :cljs t/List) x)])
;cc/list* (t/All [x] [x :* (t/Seqable x) :-> (t/NilableNonEmptyASeq x)])
cc/list* (t/All [x] (t/IFn [(t/Seqable x) :-> (t/NilableNonEmptyASeq x)]
                           [x (t/Seqable x) :-> (t/NonEmptyASeq x)]
                           [x x (t/Seqable x) :-> (t/NonEmptyASeq x)]
                           [x x x (t/Seqable x) :-> (t/NonEmptyASeq x)]
                           [x x x x (t/Seqable x) :-> (t/NonEmptyASeq x)]
                           [x x x x x (t/Seqable x) :-> (t/NonEmptyASeq x)]
                           [x x x x x x (t/Seqable x) :-> (t/NonEmptyASeq x)]
                           [x x x x x x x (t/Seqable x) :-> (t/NonEmptyASeq x)]
                           [x x x x x x x x (t/Seqable x) :-> (t/NonEmptyASeq x)]
                           [x x x x x x x x x (t/Seqable x) :-> (t/NonEmptyASeq x)]
                           [x x x x x x x x x x (t/Seqable x) :-> (t/NonEmptyASeq x)]))

cc/hash [t/Any :-> t/AnyInteger]
cc/hash-combine [t/AnyInteger t/Any :-> t/AnyInteger]
reborg/parallel
(require '[parallel.core :as p])
(require '[criterium.core :refer [bench quick-bench]])
(require '[clojure.core.reducers :as r])

(def small-overlapping
  (into [] (map hash-map
     (repeat :samplevalue)
     (concat
       (shuffle (range 0. 1e5))
       (shuffle (range 0. 1e5))
       (shuffle (range 0. 1e5))
       (shuffle (range 0. 1e5))
       (shuffle (range 0. 1e5))))))

(def big-overlapping
  (into [] (map hash-map
     (repeat :samplevalue)
     (concat
       (shuffle (range 6e4 1e5))
       (shuffle (range 6e4 1e5))
       (shuffle (range 6e4 1e5))
       (shuffle (range 6e4 1e5))
       (shuffle (range 6e4 1e5))))))

(def bigger-data
  (into [] (map hash-map
     (repeat :samplevalue)
     (concat
       (shuffle (range 0. 7e5))
       (shuffle (range 0. 7e5))
       (shuffle (range 0. 7e5))
       (shuffle (range 0. 7e5))
       (shuffle (range 0. 7e5))))))