concept input in category clojure

appears as: input, input, The input, inputs, n input, inputs
Clojure: The Essential Reference

This is an excerpt from Manning's book Clojure: The Essential Reference.

fnil generates a new function starting from another input function "f". The main use case for fnil is to decorate "f" so that it can default to optional values in case the input is nil. fnil operates positionally: "default1" will be used for a nil passed as first argument, "default2" for a nil passed as the second argument and "default3" for a nil as the third argument. fnil doesn’t support more than 3 defaults, so (fnil + 1 2 3 4) causes an exception to be thrown.

(defn forever []
  (while true                                         ; #1
    (Thread/sleep 5000)                               ; #2
    (println "App running. Waiting for input...")))

(defn status-thread []
  (let [t (Thread. forever)]                          ; #3
    (.start t)
    t))

(def t (status-thread))
;; App running. Waiting for input...
;; App running. Waiting for input...
;; App running. Waiting for input...

(.stop t)                                             ; #4
;; nil
  • fn contains an example of merge on an arbitrary number of input maps. apply can be used with merge if the input is in the form of a list of maps.
  • Figure 13.2. Chart showing how creation speed changes related to the percentage of distinct items in the input (100% means no repeating items, 0% means the input contains the same repeating element).
    37 set by distinct