Liking cljdoc? Tell your friends :D

flatland.useful.experimental


comp-partialclj

(comp-partial n & fns)

A version of comp that "rescues" the first N args, passing them to every composed function instead of just the first one.

For example, ((comp-partial 2 * +) 3 4 5 6) is equivalent to (* 3 4 (+ 3 4 5 6)).

A version of comp that "rescues" the first N args, passing them to every composed function
instead of just the first one.

For example, ((comp-partial 2 * +) 3 4 5 6) is equivalent to (* 3 4 (+ 3 4 5 6)).
sourceraw docstring

cond-letcljmacro

(cond-let test-binding then-form & more)

An implementation of cond-let that is as similar as possible to if-let. Takes multiple test-binding/then-form pairs and evalutes the form if the binding is true. Also supports :else in the place of test-binding and always evaluates the form in that case.

Example: (cond-let [b (bar 1 2 3)] (println :bar b) [f (foo 3 4 5)] (println :foo f) [b (baz 6 7 8)] (println :baz b) :else (println :no-luck))

An implementation of cond-let that is as similar as possible to if-let. Takes multiple
test-binding/then-form pairs and evalutes the form if the binding is true. Also supports
:else in the place of test-binding and always evaluates the form in that case.

Example:
 (cond-let [b (bar 1 2 3)] (println :bar b)
           [f (foo 3 4 5)] (println :foo f)
           [b (baz 6 7 8)] (println :baz b)
           :else           (println :no-luck))
sourceraw docstring

defn-wrappingcljmacro

(defn-wrapping name wrappers-var & defn-args)

Define a function as with defn, which checks the contents of wrappers-var whenever it is called. If that var is empty, the underlying defn is called without modification. Otherwise, it is treated as a list of wrapper functions, which are wrapped around the underlying implementation before it is called.

The wrappers are applied left-to-right, which means that the rightmost wrapper is outermost, and the leftmost wrapper is applied just before the base function.

The wrappers are not called "directly" on the arguments, but are instead called like Ring wrappers, to create a single function composed of all of them; the resulting function is called with the actual arguments to the defn-wrapping function.

For example, if the wrapped function is -, and the wrappers are [(fn [f] (fn [x] (* 2 (f x)))), (fn [f] (fn [x] (f (+ 10 x))))], then the eventual function will behave like (fn [x] (* 2 (- (+ 10 x)))).

Swapping the order of the wrappers would yield a function behaving like (fn [x] (* 2 (+ 10 (- x)))).

Note the order of the wrapping: when called with 10 as an argument, the former will return -40, and the latter 0.

Define a function as with defn, which checks the contents of wrappers-var
whenever it is called. If that var is empty, the underlying defn is called
without modification. Otherwise, it is treated as a list of wrapper functions,
which are wrapped around the underlying implementation before it is called.

The wrappers are applied left-to-right, which means that the rightmost
wrapper is outermost, and the leftmost wrapper is applied just before the base
function.

The wrappers are not called "directly" on the arguments, but are
instead called like Ring wrappers, to create a single function composed of
all of them; the resulting function is called with the actual arguments to
the defn-wrapping function.

For example, if the wrapped function is -, and the wrappers are
[(fn [f] (fn [x] (* 2 (f x)))), (fn [f] (fn [x] (f (+ 10 x))))],
then the eventual function will behave like (fn [x] (* 2 (- (+ 10 x)))).

Swapping the order of the wrappers would yield a function behaving like
(fn [x] (* 2 (+ 10 (- x)))).

Note the order of the wrapping: when called with 10 as an argument, the former
will return -40, and the latter 0.
sourceraw docstring

fixesclj

(fixes x & clauses)

Like fix, but each clause is tested whether or not the previous clauses matched, so multiple transformations may be applied. Unlike fix, fixes does not support a final one-element "pair".

Like fix, but each clause is tested whether or not the previous clauses matched, so multiple
transformations may be applied. Unlike fix, fixes does not support a final one-element "pair".
sourceraw docstring

let-ifcljmacro

(let-if test bindings & forms)

Choose a set of bindings based on the result of a conditional test.

Example: (let-if (even? a) [b (bar 1 2 3) (baz 1 2 3) c (foo 1) (foo 3)] (println (combine b c)))

Choose a set of bindings based on the result of a conditional test.

Example:
 (let-if (even? a)
         [b (bar 1 2 3) (baz 1 2 3)
          c (foo 1)     (foo 3)]
   (println (combine b c)))
sourceraw docstring

lift-metaclj

(lift-meta m & ks)

Move some of the keys from m into its metadata, overriding existing values. (lift-meta {:a 1 :b 2} [:a]) -> ^{:a 1} {:b 2}

Move some of the keys from m into its metadata, overriding existing values.
(lift-meta {:a 1 :b 2} [:a]) -> ^{:a 1} {:b 2}
sourceraw docstring

make-wrappable!clj

(make-wrappable! fn-var wrappers-var & [name])
source

order-let-ifcljmacro

(order-let-if pred bindings & body)

If predicate is true, bind the names provided, otherwise reverse those bindings.

Example: (order-let-if false [a "foo" b "bar"] [a b]) = ["bar" "foo"]

If predicate is true, bind the names provided, otherwise reverse those bindings.

Example:
 (order-let-if false [a "foo" b "bar"] [a b]) = ["bar" "foo"]
sourceraw docstring

prefix-lookupclj

(prefix-lookup prefix-map)

Takes a map whose keys are names, and returns a function that does fast prefix matching on its input against the names in the original map, returning the first value whose key is a prefix.

If order is important (eg because your prefixes overlap, or you want to test common prefixes first for performance), you can pass a sequence of pairs instead of a map.

Takes a map whose keys are names, and returns a function that does fast prefix
matching on its input against the names in the original map, returning the
first value whose key is a prefix.

If order is important (eg because your prefixes overlap, or you want to test
common prefixes first for performance), you can pass a sequence of pairs
instead of a map.
sourceraw docstring

protocol-stubcljmacro

(protocol-stub name proto-specs)

Define a new type of record implementing the specified protocols. Its constructor will take two arguments:

  • An object which already satisfies the given protocols. This object will be delegated to for functions which are not stubbed out.
  • A "log" function to be called (for side effects) every time a protocol function is called. For functions marked as :stub (see below), the log function will be called with two arguments: the function name (an unqualified symbol), and the arglist (including "this"). Functions marked :forward will have a third argument, the function's return value. Use this function to implement your logging (or whatever else).

The macro itself needs two arguments: the name of the record to define, and:

  • A map of protocol stubbing specifications. Each key should be a protocol, and the value another map. It may have zero or more of these keys:
    • A :default key specifying either :stub or :forward, to control whether the underlying implementation is called after logging. Defaults to :stub, meaning that only the logging function will be called, completely stubbing out the backing implementation.
    • An :exceptions key, listing the functions of this protocol that should behave the opposite of the :default.
Define a new type of record implementing the specified protocols. Its
constructor will take two arguments:
  - An object which already satisfies the given protocols. This object will
    be delegated to for functions which are not stubbed out.
  - A "log" function to be called (for side effects) every time a protocol
    function is called. For functions marked as :stub (see below), the
    log function will be called with two arguments: the function name (an
    unqualified symbol), and the arglist (including "this"). Functions
    marked :forward will have a third argument, the function's return value.
    Use this function to implement your logging (or whatever else).

The macro itself needs two arguments: the name of the record to define, and:
  - A map of protocol stubbing specifications. Each key should be a protocol,
    and the value another map. It may have zero or more of these keys:
    - A :default key specifying either :stub or :forward, to control whether
      the underlying implementation is called after logging. Defaults to :stub,
      meaning that only the logging function will be called, completely
      stubbing out the backing implementation.
    - An :exceptions key, listing the functions of this protocol that should
      behave the opposite of the :default.
sourceraw docstring

while-letcljmacro

(while-let bindings & body)

Repeatedly executes body, which presumably has side-effects, while let binding is not false.

Repeatedly executes body, which presumably has side-effects, while let binding is not false.
sourceraw docstring

with-wrappercljmacro

(with-wrapper wrappers-var wrap-fn & body)

Dynamically bind an additional wrapper to the specified wrapper-var (see defn-wrapping). The wrapper function will be conj-ed onto the current set of wrappers.

Dynamically bind an additional wrapper to the specified wrapper-var
(see defn-wrapping). The wrapper function will be conj-ed onto the current
set of wrappers.
sourceraw docstring

with-wrapperscljmacro

(with-wrappers wrappers-var wrap-fns & body)

Dynamically bind some additional wrappers to the specified wrapper-var (see defn-wrapping). Each wrapper function will be conj-ed onto the current set of wrappers.

Dynamically bind some additional wrappers to the specified wrapper-var
(see defn-wrapping). Each wrapper function will be conj-ed onto the current
set of wrappers.
sourceraw docstring

wrap-multiplecljmacro

(wrap-multiple wrappers-var & fn-syms)
source

wrap-withclj

(wrap-with f wrapper-var & [name])
source

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

× close