Liking cljdoc? Tell your friends :D

hara.function.base.macro


applymcljmacro

(applym macro & args)

Allow macros to be applied to arguments just like functions

(applym const '((+ 1 2))) => 3

(macroexpand '(applym const '((+ 1 2)))) => 3

Allow macros to be applied to arguments just like functions

(applym const '((+ 1 2))) => 3

(macroexpand '(applym const '((+ 1 2))))
=> 3
raw docstring

constcljmacro

(const body)

converts an expression into a constant at compile time

(const (+ 1 2)) => 3

(macroexpand '(const (+ 1 2))) => 3

converts an expression into a constant at compile time

(const (+ 1 2)) => 3

(macroexpand '(const (+ 1 2))) => 3
raw docstring

create-argsclj

(create-args [doc? attr? & more :as arglist])

caches the result of a function

(create-args '[[x] (inc x) nil nil]) => '("" {} [x] (inc x))

caches the result of a function

(create-args '[[x] (inc x) nil nil])
=> '("" {} [x] (inc x))
raw docstring

create-def-formclj

(create-def-form name attrs body)
(create-def-form name doc attrs arglist body)

removes a cached result

(create-def-form 'hello "doc" {:added "1.3"} '[x] '(inc x)) '(do (def hello (inc x)) (clojure.core/doto (var hello) (clojure.core/alter-meta! clojure.core/merge {:added "1.3"} {:arglists (quote ([x])), :doc "doc"})))

removes a cached result

(create-def-form 'hello "doc" {:added "1.3"} '[x] '(inc x))
'(do (def hello (inc x))
     (clojure.core/doto (var hello)
       (clojure.core/alter-meta! clojure.core/merge
                                 {:added "1.3"}
                                 {:arglists (quote ([x])), :doc "doc"})))
raw docstring

defcomposecljmacro

(defcompose name doc? attrs? & [arglist body])

used instead of def for functional composition

(defcompose -add-10- [x & more] (partial + 10))

(-add-10- 10) => 20

used instead of `def` for functional composition

(defcompose -add-10-
  [x & more]
  (partial + 10))

(-add-10- 10) => 20
raw docstring

deflookupcljmacro

(deflookup name doc? attrs? & [arglist lookup transfer?])

defines a map based lookup

(deflookup -country- [city] {:kunming :china :melbourne :australia})

(-country- :kunming) => :china

defines a map based lookup

(deflookup -country-
  [city]
  {:kunming :china
   :melbourne :australia})

(-country- :kunming) => :china
raw docstring

lookupclj

(lookup m)
(lookup m {:keys [in out not-found] :as transfer})

creates a lookup function based on a map lookup

(def -opts- {:in (fn [s] (-> s (.toLowerCase) keyword)) :out name :not-found :no-reference})

(def -lookup- (lookup {:kunming :china :melbourne :australia} -opts-))

(-lookup- "MeLBoURne") => "australia"

creates a lookup function based on a map lookup

(def -opts-
  {:in  (fn [s] (-> s (.toLowerCase) keyword))
   :out name
   :not-found :no-reference})

(def -lookup-
  (lookup {:kunming :china
           :melbourne :australia}
          -opts-))

(-lookup- "MeLBoURne") => "australia"
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close