Public Vars

Back

constantly (clj)

(source)

function

(constantly x)
Returns a function that takes any number of arguments and returns x.

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 render-slider
  '(fn [state-atom]
     [:input {:type :range :value @state-atom :on-change #(swap! state-atom (constantly (int (.. % -target -value))))}]))

(def render-text-input
  '(fn [state-atom]
     [:input {:type :text :value @state-atom :on-change #(swap! state-atom (constantly (.. % -target -value)))
              :class "px-3 py-3 placeholder-blueGray-300 text-blueGray-600 relative bg-white bg-white rounded text-sm border border-blueGray-300 outline-none focus:outline-none focus:ring w-full"}]))

(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/not [t/Any :-> t/Bool]
cc/constantly (t/All [x] [x :-> [t/Any :* :-> x]])
bsless/more.async
(ns more.async.dataflow.node
  (:require
   [clojure.spec.alpha :as s]
   [clojure.core.async :as a]
   [more.async :as ma]
   [clojure.data]))

(defmethod -compile ::batch
  [{{from ::from
     to ::to
     size ::size
     timeout ::timeout
     rf ::rf
     init ::init-fn
     finally ::finally-fn
     async? ::async?
     :or {rf conj init (constantly []) finally identity}}
    ::batch} env]
  (let [from (env from)
        to (env to)]
    (if async?
      (ma/batch! from to size timeout rf init finally)
      (a/thread (ma/batch!! from to size timeout rf init finally)))))

(comment
  (s/explain-data
   ::pubsub
   {::pub :in
    ::topic-fn (constantly 0)
    ::sub [{::topic 0 ::name ::out}]}))
serioga/webapp-clojure-2020
(ns app.$-example.handler.index
  (:require [app.$-example.impl.handler :as impl]
            [app.$-example.impl.html :as html]
            [lib.clojure.core :as c]))

(c/add-method impl/route-path :route/index (constantly "/"))
serioga/webapp-clojure-2020
(ns app.$-example.handler.example-react
  (:require [app.$-example.impl.handler :as impl]
            [app.$-example.impl.html :as html]
            [app.rum.mount :as rum.mount]
            [lib.clojure.core :as c]))

(c/add-method impl/route-path :route/example-react (constantly "/example-react"))