Public Vars

Back

shuffle (clj)

(source)

function

(shuffle coll)
Return a random permutation of coll

Examples

jepsen-io/jepsen
(ns yugabyte.ycql.bank
  (:refer-clojure :exclude [test])
  (:require [clojure.tools.logging :refer [debug info warn]]
            [clojure.core.reducers :as r]
            [jepsen.client :as client]
            [jepsen.checker :as checker]
            [jepsen.generator :as gen]
            [jepsen.tests.bank :as bank]
            [jepsen.checker.timeline :as timeline]
            [knossos.op :as op]
            [clojurewerkz.cassaforte.client :as cassandra]
            [clojurewerkz.cassaforte.cql :as cql]
            [clojurewerkz.cassaforte.query :as q :refer :all]
            [yugabyte.ycql.client :as c]))

  (invoke! [this test op]
    (c/with-errors op #{:read}
      (case (:f op)
        :read
        (let [as (shuffle (:accounts test))]
          (->> as
               (mapv (fn [x]
                       ;; TODO - should be wrapped in a transaction after we
                       ;; support transactions with selects.
                       (->> (cql/select-with-ks conn keyspace
                                                (str table-name x)
                                                (where [[= :id x]]))
                            first
                            :balance)))
               (zipmap as)
               (assoc op :type :ok, :value)))
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))))

cc/shuffle (t/All [x] 
                  #?(:clj (t/IFn [(t/I (Collection x) (t/Seqable x)) :-> (t/Vec x)]
                                 [(Collection x) :-> (t/Vec x)])
                     :cljs [(t/Seqable x) :-> (t/Vec x)]))
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))))))
clojure/data.int-map
(ns clojure.data.benchmark
  (:use
    [clojure.test])
  (:require
    [clojure.core.reducers :as r]
    [clojure.data.int-map :as i]
    [criterium.core :as c])
  (:import
    [java.util
     BitSet]
    [clojure.data.int_map
     PersistentIntMap]))

(def ordered-entries (vec (map vector (range n) (range n))))
(def entries (vec (shuffle ordered-entries)))
dco-dev/interval-tree
(ns com.dean.interval-tree.tree.ordered-set
  (:require [clojure.core.reducers       :as r :refer [coll-fold]]
            [clojure.set]
            [com.dean.interval-tree.tree.node     :as node]
            [com.dean.interval-tree.tree.order    :as order]
            [com.dean.interval-tree.tree.protocol :as proto]
            [com.dean.interval-tree.tree.root]
            [com.dean.interval-tree.tree.tree     :as tree])
  (:import  [clojure.lang                RT]
            [com.dean.interval_tree.tree.protocol PExtensibleSet]
            [com.dean.interval_tree.tree.root     INodeCollection
                                         IBalancedCollection
                                         IOrderedCollection]))

  (def foo (shuffle (range 500000)))
  (def bar (shuffle (range 1000000)))

  (def s0 (shuffle (range 0 1000000 2)))
  (def s1 (shuffle (range 0 1000000 3)))