Public Vars

Back

dedupe (clj)

(source)

function

(dedupe) (dedupe coll)
Returns a lazy sequence removing consecutive duplicates in coll. Returns a transducer when no collection is provided.

Examples

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/map-indexed (t/All [x y] (t/IFn [[t/Int x :-> y] :-> (t/Transducer x y)]
                                   [[t/Int x :-> y] (t/Seqable x) :-> (t/ASeq y)]))
cc/keep-indexed (t/All [a c] (t/IFn [[t/Int a :-> (t/U nil c)] :-> (t/Transducer a c)]
                                    [[t/Int a :-> (t/U nil c)] (t/Seqable a) :-> (t/Seq c)]))
cc/bounded-count [(t/U t/Counted t/AnySeqable) :-> t/Int]
cc/keep (t/All [a b] (t/IFn [[a :-> (t/Option b)] :-> (t/Transducer a b)]
                            [[a :-> (t/Option b)] (t/Seqable a) :-> (t/ASeq b)]))
cc/dedupe (t/All [x] (t/IFn [:-> (t/Transducer x x)]
                            [(t/Seqable x) :-> (t/ASeq x)]))
cc/random-sample (t/All [x] (t/IFn [t/Num :-> (t/Transducer x x)]
                                   [t/Num (t/Seqable x) :-> (t/ASeq x)]))
cc/halt-when (t/All [x] (t/IFn [[x :-> t/Any] 
                                ;; TODO opens a can of worms. requires knowledge of transduction context.
                                ;; overrides final value of `into`, while doing nothing in `sequence`.
                                ;(t/Option [t/Any v :-> t/Any]) :?
                                :-> (t/Transducer x x)]
                               ))
howonlee/mertonon
(ns mertonon.services.matrix-service-test
  (:require [clojure.core.matrix :as cm]
            [clojure.data :as cd]
            [clojure.test :refer :all]
            [clojure.test.check :as tc]
            [clojure.test.check.clojure-test :refer :all]
            [clojure.test.check.generators :as gen]
            [clojure.test.check.properties :as prop]
            [mertonon.generators.aug-net :as aug-net-gen]
            [mertonon.generators.net :as net-gen]
            [mertonon.services.graph-service :as gs]
            [mertonon.services.matrix-service :as ms]
            [mertonon.test-utils :as tu]))

                      inp-layer-uuids       (gs/initial-layer-uuids curr-graph)
                      out-layer-uuids       (gs/terminal-layer-uuids curr-graph)
                      orig-input-cobjs      (-> (for [inp-layer-uuid inp-layer-uuids]
                                                  (cost-objects-by-layer inp-layer-uuid))
                                                flatten vec)
                      orig-output-cobjs     (-> (for [out-layer-uuid out-layer-uuids]
                                                  (cost-objects-by-layer out-layer-uuid))
                                                flatten vec)
                      orig-inp              {:entries             orig-entries
                                             :pattern-layer-uuids (-> (into inp-layer-uuids out-layer-uuids)
                                                                      sort dedupe vec)
                                             :cost-objects            (->> (into orig-input-cobjs orig-output-cobjs)
                                                                       (sort-by :uuid)
                                                                       vec)}
                      trans-out             (ms/entries->patterns orig-inp)
                      involuted-inp         (ms/patterns->entries trans-out)]