Public Vars

Back

var? (clj)

(source)

function

(var? v)
Returns true if v is of type clojure.lang.Var

Examples

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

(def var-viewer
  {:pred var?
   :transform-fn transform-var
   :render-fn '(fn [x] [nextjournal.clerk.render/inspect @x])})

(def convenient-slider
  {:transform-fn (comp transform-var (clerk/update-val #(cond-> % (viewer/get-safe % ::clerk/var-from-def) ::clerk/var-from-def)))
   :render-fn '(fn [x] (let [state-atom (cond-> x (var? x) deref)]
                         [:input {:type :range :value @state-atom :on-change #(swap! state-atom (constantly (int (.. % -target -value))))}]))})
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/integer? (t/Pred t/AnyInteger)
cc/int? (t/Pred #?(:clj (t/U Long
                             Integer
                             Short
                             Byte)
                   :cljs (t/U t/CLJSInteger
                              goog.math.Integer
                              goog.math.Long)))
cc/pos-int? [t/Any :-> t/Bool
             :filters {:then (is #?(:clj (t/U Long
                                              Integer
                                              Short
                                              Byte)
                                    :cljs (t/U t/CLJSInteger
                                               goog.math.Integer
                                               goog.math.Long)) 0)}]
cc/neg-int? [t/Any :-> t/Bool
             :filters {:then (is #?(:clj (t/U Long
                                              Integer
                                              Short
                                              Byte)
                                    :cljs (t/U t/CLJSInteger
                                               goog.math.Integer
                                               goog.math.Long)) 0)}]
cc/nat-int? [t/Any :-> t/Bool
             :filters {:then (is #?(:clj (t/U Long
                                              Integer
                                              Short
                                              Byte)
                                    :cljs (t/U t/CLJSInteger
                                               goog.math.Integer
                                               goog.math.Long)) 0)}]
cc/number? (t/Pred t/Num)
cc/double? (t/Pred #?(:clj Double
                      :cljs t/Num))
cc/float? (t/Pred #?(:clj (t/U Double Float)
                     :cljs t/Num))
cc/ident? (t/Pred t/Ident)
cc/simple-ident? [t/Any :-> t/Bool :filters {:then (is t/Ident 0)}]
cc/qualified-ident? [t/Any :-> t/Bool :filters {:then (is t/Ident 0)}]
cc/simple-symbol? [t/Any :-> t/Bool :filters {:then (is t/Sym 0)}]
cc/qualified-symbol? [t/Any :-> t/Bool :filters {:then (is t/Sym 0)}]
cc/simple-keyword? [t/Any :-> t/Bool :filters {:then (is t/Kw 0)}]
cc/qualified-keyword? [t/Any :-> t/Bool :filters {:then (is t/Kw 0)}]
cc/var? (t/Pred t/AnyVar)
clojure-numerics/expresso
(ns numeric.expresso.test-core
  (:use numeric.expresso.core)
  (:use [clojure.test :exclude [test-vars]])
  (:require [numeric.expresso.types :as types]
            [numeric.expresso.protocols :as protocols]
            [clojure.core.logic :as logic]))

(deftest test-shape
  (is (= [] (shape (ex (+ 1 2)))))
  (is (logic/lvar? (shape (matrix-symbol 'x)))))

(deftest test-expresso-symbol
  (is (= 'x (expresso-symbol 'x)))
  (is (= types/number (protocols/type-of (expresso-symbol 'x))))
  (is (= types/matrix
         (protocols/type-of (expresso-symbol 'x :type types/matrix))))
  (is (= types/matrix
         (protocols/type-of (expresso-symbol 'x :shape [2 3]))))
  (is (= [] (shape (expresso-symbol 'x))))
  (is (logic/lvar? (shape (expresso-symbol 'x :type types/matrix))))
  (is (= [2 2] (shape (expresso-symbol 'x :shape [2 2])))))


(deftest test-matrix-symbol
  (is (= types/matrix
         (protocols/type-of (matrix-symbol 'x))))
  (is (logic/lvar? (shape (matrix-symbol 'x))))
  (is (= [2 2] (shape (matrix-symbol 'x :shape [2 2])))))