Public Vars

Back

subseq (clj)

(source)

function

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

Examples

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

(defun start-kbd-macro (append &optional no-exec)
  "Record subsequent keyboard input, defining a keyboard macro.
  The commands are recorded even as they are executed.
  Use M-x end-kbd-macro to finish recording and make the macro available.
  Use M-x name-last-kbd-macro to give it a permanent name.
  Non-nil arg (prefix arg) means append to last macro defined;
  this begins by re-executing that macro as if you typed it again.
  If optional second arg, NO-EXEC, is non-nil, do not re-execute last
  macro before appending to it."
  (interactive "P"))

(defun defining-kbd-macro (append &optional no-exec)
  "Record subsequent keyboard input, defining a keyboard macro.
  The commands are recorded even as they are executed.
  Use M-x end-kbd-macro to finish recording and make the macro available.
  Use M-x name-last-kbd-macro to give it a permanent name.
  Non-nil arg (prefix arg) means append to last macro defined;
  this begins by re-executing that macro as if you typed it again.
  If optional second arg, NO-EXEC, is non-nil, do not re-execute last
  macro before appending to it."
  )
hraberg/deuce
(ns deuce.emacs.print
  (:use [deuce.emacs-lisp :only (defun defvar)])
  (:require [clojure.core :as c]
            [clojure.string :as s]
            [deuce.emacs.buffer :as buffer]
            [deuce.emacs.data :as data]
            [deuce.emacs.editfns :as editfns]
            [deuce.emacs.fns :as fns])
  (:refer-clojure :exclude [print]))

(defvar print-circle nil
  "*Non-nil means print recursive structures using #N= and #N# syntax.
  If nil, printing proceeds recursively and may lead to
  `max-lisp-eval-depth' being exceeded or an error may occur:
  \"Apparently circular structure being printed.\"  Also see
  `print-length' and `print-level'.
  If non-nil, shared substructures anywhere in the structure are printed
  with `#N=' before the first occurrence (in the order of the print
  representation) and `#N#' in place of each subsequent occurrence,
  where N is a positive decimal integer.")
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)))))))
aliostad/deep-learning-lang-detection
(ns fluxion-test
  (:require [clojure.core.async :refer [chan <!! onto-chan]]
            [fluxion :refer :all]
            [clojure.test :refer :all]
            [clojure.set :as set]
            [clojure.data.generators :as gen]
            [clojure.test.generative :refer [defspec]]
            [clojure.test.generative.runner :as runner]))

;; Do too much math so that missing one beat doesn't mean each
;; subsequent beat is 100% error in the check.
(defspec timer-is-roughly-periodic
  (fn [interval beats]
    (let [t (timer interval)
          ticks (loop [ticks []
                       beats-to-go beats]
                  (if (< 0 beats-to-go)
                    (recur (conj ticks (<!! t))
                           (dec beats-to-go))
                    ticks))
          lt (last ticks)
          target-schedule (take-while #(<= % lt) (iterate (partial + interval) (first ticks)))]
      [ticks target-schedule]))
  [^{:tag (gen/uniform 80 120)} interval ^{:tag (gen/uniform 80 120)} beats]
  (let [ticks (first %)
        target-schedule (nth % 1)
        error (memoize (fn [target observed]
                         (Math/abs (- target observed))))
        errors (into {}
                     (map
                      (fn [[k v]]
                        [k (sort-by last v)])
                      (group-by first
                                (for [target target-schedule]
                                  (let [nearest-tick (apply min-key
                                                            (partial error target)
                                                            ticks)]
                                    [nearest-tick target (error target nearest-tick)])))))
        tick-errors (for [tick ticks]
                      (/ (or (last (first (errors tick)))
                             interval) interval))
        avg-error (/ (apply + tick-errors) (count tick-errors))
        picked-targets  (map #(nth (first %) 1) (vals errors))
        missed-targets (set/difference (set target-schedule)
                                       (set picked-targets))]
    (assert (<= avg-error 1/10) (str "Average error " 1/10 " greater than " 1/10))
    (assert (< (/ (count missed-targets) beats) 1/10)
            (str "Missed target points " (count missed-targets)
                 " greater than " (* 1/10 beats)))))