Public Vars

Back

next (clj)

(source)

variable

(next coll)
Returns a seq of the items after the first. Calls seq on its argument. If there are no more items, returns nil.

Examples

clojure
(ns clojure.test-clojure.server
    (:import java.util.Random)
    (:require [clojure.test :refer :all])
    (:require [clojure.core.server :as s]))

(defn create-random-thread
  []
  (Thread.
    (fn []
      (let [random (new Random)]
      (while (not (.isInterrupted (Thread/currentThread)))
        (System/setProperty (Integer/toString (.nextInt random)) (Integer/toString (.nextInt random))))))))
nextjournal/clerk
(ns viewers.controls
  "Demo of Clerk's two-way bindings."
  {:nextjournal.clerk/visibility {:code :show :result :show}}
  (:require [clojure.core :as core]
            [nextjournal.clerk :as clerk]
            [nextjournal.clerk.viewer :as viewer]))

^{::clerk/viewer {:transform-fn transform-var
                  :render-fn '#(vector nextjournal.clerk.render/inspect @%)}}
#'number-atom

(def var-viewer
  {:pred var?
   :transform-fn transform-var
   :render-fn '(fn [x] [nextjournal.clerk.render/inspect @x])})
clojure/core.typed
(ns clojure.core.typed.test.poly-record
  (:require [clojure.core.typed :as t]))

      ;polymorphic
      (defrecord> [[x :variance :covariant]]
        FooP [a :- x,
              b :- Number]
        Object
        (toString [this] \"\"))"
  [& args]
  (let [vbnd (when (vector? (first args))
               (first args))
        args (if vbnd
               (next args)
               args)
        [nme fields & args] args]
    `(do (ann-record
           ~@(concat (when vbnd
                       [vbnd])
                     nme
                     fields))
         (defrecord ~nme ~(mapv first (partition 3 fields))
           ~@args))))
  )
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))))

clojure.zip/zipper [[t/Any :-> t/Any] [t/AnySeqable :-> (t/U nil (t/Seq t/Any))] 
                    [t/Any (t/U nil (t/Seq t/Any)) :-> t/Any]
                    t/Any 
                    :-> (t/Vec t/Any)]
clojure.zip/seq-zip [t/Any :-> (t/Vec t/Any)]
clojure.zip/vector-zip [t/Any :-> (t/Vec t/Any)]
clojure.zip/xml-zip [t/Any :-> (t/Vec t/Any)]
clojure.zip/node [(t/Vec t/Any) :-> t/Any]
clojure.zip/branch? [(t/Vec t/Any) :-> t/Bool]
clojure.zip/children [(t/Vec t/Any) :-> (t/U nil (t/Seq t/Any))]
clojure.zip/root [(t/Vec t/Any) :-> t/Any]
clojure.zip/rightmost [(t/Vec t/Any) :-> (t/Vec t/Any)]
clojure.zip/right [(t/Vec t/Any) :-> t/Any]
clojure.zip/up [(t/Vec t/Any) :-> (t/U nil (t/Vec t/Any))]
clojure.zip/rights [(t/Vec t/Any) :-> t/Any]
clojure.zip/replace [(t/Vec t/Any) t/Any :-> (t/Vec t/Any)]
clojure.zip/down [(t/Vec t/Any) :-> (t/U (t/Vec t/Any) nil)]
clojure.zip/left [(t/Vec t/Any) :-> (t/U (t/Vec t/Any) nil)]
clojure.zip/lefts [(t/Vec t/Any) :-> (t/U (t/Vec t/Any) nil)]
clojure.zip/leftmost [(t/Vec t/Any) :-> (t/U (t/Vec t/Any) nil)]
clojure.zip/append-child [(t/Vec t/Any) t/Any :-> (t/Vec t/Any)]
clojure.zip/branch? [(t/Vec t/Any) :-> t/Bool]
clojure.zip/end? [(t/Vec t/Any) :-> t/Bool]
clojure.zip/insert-child [(t/Vec t/Any) t/Any :-> (t/Vec t/Any)]
clojure.zip/insert-left [(t/Vec t/Any) t/Any :-> (t/Vec t/Any)]
clojure.zip/insert-right [(t/Vec t/Any) t/Any :-> (t/Vec t/Any)]
clojure.zip/next [(t/Vec t/Any) :-> (t/Vec t/Any)]
clojure.zip/prev [(t/Vec t/Any) :-> (t/U (t/Vec t/Any) nil)]
;; more to say here
clojure.zip/path [(t/Vec t/Any) :-> t/Any]
clojure.zip/remove [(t/Vec t/Any) :-> (t/Vec t/Any)]

cc/first (t/All [x] (t/IFn [(t/HSequential [x t/Any :*]) :-> x
                            :object {:id 0 :path [(Nth 0)]}]
                           [(t/EmptySeqable x) :-> nil]
                           [(t/NonEmptySeqable x) :-> x]
                           [(t/Seqable x) :-> (t/Option x)]))
cc/second (t/All [x] (t/IFn [(t/HSequential [t/Any x t/Any :*]) :-> x
                             :object {:id 0 :path [(Nth 1)]}]
                            [(t/Option (t/I (t/Seqable x) (t/CountRange 0 1))) :-> nil]
                            [(t/I (t/Seqable x) (t/CountRange 2)) :-> x]
                            [(t/Seqable x) :-> (t/Option x)]))
cc/ffirst (t/All [x] [(t/Seqable (t/Seqable x)) :-> (t/Nilable x)])
cc/nfirst (t/All [x] [(t/Seqable (t/Seqable x)) :-> (t/NilableNonEmptyASeq x)])
cc/group-by (t/All [x y] [[x :-> y] (t/Seqable x) :-> (t/Map y (t/NonEmptyAVec x))])
cc/fnext (t/All [x] [(t/Seqable x) :-> (t/Option x)])
cc/nnext (t/All [x] [(t/Seqable x) :-> (t/NilableNonEmptyASeq x)])
cc/nthnext (t/All [x] (t/IFn [nil t/AnyInteger :-> nil]
                             [(t/Seqable x) t/AnyInteger :-> (t/NilableNonEmptyASeq x)]))
cc/rest (t/All [x] [(t/Seqable x) :-> (t/ASeq x)])
cc/last (t/All [x] (t/IFn [(t/NonEmptySeqable x) :-> x]
                          [(t/Seqable x) :-> (t/U nil x)]))
cc/butlast (t/All [x] [(t/Seqable x) :-> (t/NilableNonEmptyASeq x)])
cc/next (t/All [x] (t/IFn [(t/Option (t/Coll x)) :-> (t/NilableNonEmptyASeq x)
                           :filters {:then (& (is (t/CountRange 2) 0)
                                              (! nil 0))
                                     :else (| (is (t/CountRange 0 1) 0)
                                              (is nil 0))}]
                          [(t/Seqable x) :-> (t/NilableNonEmptyASeq x)]))
probprog/anglican
(ns anglib.state-space
  (:require [clojure.core.matrix :as m])
  (:use [anglican emit runtime]))

(defproc LDS
  "Linear Dynamical System (i.e. Kalman Filter). "
  [init-mean init-cov obs-matrix obs-cov trans-matrix trans-cov]
  [mu nil V nil]
  (produce [this]
     (if V
       ;; distribution on next observation
       (let [P (m/add trans-cov
                      (m/mmul trans-matrix
                              (m/mmul V
                                      (m/transpose trans-matrix))))]
         (mvn (m/mmul obs-matrix
                      (m/mmul trans-matrix mu))
              (m/add obs-cov
                     (m/mmul obs-matrix
                             (m/mmul P
                                     (m/transpose obs-matrix))))))
       ;; distribution on initial observation
       (mvn (m/mmul obs-matrix init-mean)
            (m/add obs-cov
                   (m/mmul obs-matrix
                           (m/mmul init-cov
                                   (m/transpose obs-matrix)))))))
  (absorb [this y]
     (if V
       ;; update mu and V (see Bishop 13.88-13.92)
       (let [P (m/add trans-cov
                      (m/mmul trans-matrix
                              (m/mmul V
                                      (m/transpose trans-matrix))))
             K (m/mmul P
                       (m/mmul (m/transpose trans-matrix)
                               (m/inverse
                                (m/add obs-cov
                                       (m/mmul obs-matrix
                                               (m/mmul P
                                                       (m/transpose obs-matrix)))))))
             Amu (m/mmul trans-matrix mu)
             mu (m/add Amu
                       (m/mmul K
                               (m/sub y
                                      (m/mmul obs-matrix
                                              Amu))))
             I (apply m/identity-matrix (m/shape K))
             V (m/mmul (m/sub I
                              (m/mmul K
                                      obs-matrix))
                       P)]
          (LDS init-mean init-cov
               obs-matrix obs-cov
               trans-matrix trans-cov
               mu V))
       ;; initialize mu and V (see Bishop 13.94-13.97)
       (let [K (m/mmul init-cov
                       (m/mmul (m/transpose obs-matrix)
                               (m/inverse
                                 (m/mmul obs-matrix
                                         (m/mmul init-cov
                                                 (m/transpose obs-matrix))))))
             mu (m/add init-mean
                       (m/mmul K
                               (m/sub y
                                      (m/mmul obs-matrix
                                              init-mean))))
             I (apply m/identity-matrix (m/shape K))
             V (m/mmul (m/sub I
                              (m/mmul K
                                      obs-matrix))
                       init-cov)]
         (LDS init-mean init-cov
              obs-matrix obs-cov
              trans-matrix trans-cov
              mu V)))))