Public Vars

Back

rsubseq (clj)

(source)

function

(rsubseq sc test key) (rsubseq sc start-test start-key end-test end-key)
sc must be a sorted collection, test(s) one of <, <=, > or >=. Returns a reverse seq of those entries with keys ek for which (test (.. sc comparator (compare ek key)) 0) is true

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/instance? [#?(:clj Class :cljs js/Object) t/Any :-> t/Bool]
cc/cons (t/All [x] [x (t/Seqable x) :-> (t/ASeq x)])
cc/reverse (t/All [x] [(t/Seqable x) :-> (t/ASeq x)])
cc/rseq (t/All [x] [(t/Reversible x) :-> (t/NilableNonEmptyASeq x)])
cc/subseq  (t/All [x e] [(t/I (t/Seqable e) (t/Sorted x)) [t/Int t/Int :-> t/Bool] t/Int (t/cat [t/Int t/Int :-> t/Bool] t/Int) :? :-> (t/Nilable (t/ASeq e))])
cc/rsubseq (t/All [x e] [(t/I (t/Seqable e) (t/Sorted x)) [t/Int t/Int :-> t/Bool] t/Int (t/cat [t/Int t/Int :-> t/Bool] t/Int) :? :-> (t/Nilable (t/ASeq e))])
bsless/clj-fast
(ns clj-fast.clojure.core-test
  (:require [clj-fast.clojure.core :as sut]
            [clojure.test :as t]))

(t/deftest test-subseq
  (let [s1 (range 100)
        s2 (into (sorted-set) s1)]
    (doseq [i (range 100)]
      (t/is (= s1 (concat (sut/subseq s2 < i) (sut/subseq s2 >= i))))
      (t/is (= (reverse s1) (concat (sut/rsubseq s2 >= i) (sut/rsubseq s2 < i)))))))