Public Vars

Back

bounded-count (clj)

(source)

function

(bounded-count n coll)
If coll is counted? returns its count, else will count at most the first n elements of coll using its seq

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)]
                               ))