Functions for manipulating functions and producing other functions
Functions for manipulating functions and producing other functions
(apply-n-times n f x)Applies function {f} {n} times with a starting value of {x} For example: (apply-n-times 2 inc 0) is equivalent to (inc (inc 0)) (apply-n-times 3 inc 5) is equivalent to (inc (inc (inc 5)))
Applies function {f} {n} times with a starting value of {x}
For example:
(apply-n-times 2 inc 0) is equivalent to (inc (inc 0))
(apply-n-times 3 inc 5) is equivalent to (inc (inc (inc 5)))
(cache-most-recent-ret a f)Returns a fn that when called, passes the args to f and caches the return value in the atom a
Returns a fn that when called, passes the args to f and caches the return value in the atom a
(defnmem name & fndef)Defines a memoized function Examples: (defnmem fibonacci [x] (if (or (= 0 x) (= 1 x)) 1 (+ (fibonacci (- x 1)) (fibonacci (- x 2)))))
Defines a memoized function
Examples:
(defnmem fibonacci [x]
(if (or (= 0 x)
(= 1 x))
1
(+ (fibonacci (- x 1))
(fibonacci (- x 2)))))
(ignore-args f)Takes a zero-arity function and wraps it to take any args and ignore them
Takes a zero-arity function and wraps it to take any args and ignore them
(inverse f)Returns a function that returns the additive inverse (negative) of what the input function would return
Example: ((inverse (constantly 2))) => -2
Returns a function that returns the additive inverse (negative) of what the input function would return Example: ((inverse (constantly 2))) => -2
(loop-in-background-thread! f sleep-seconds)(loop-in-background-thread! f sleep-seconds sleep-millis)(map-paginated f
&
{:keys [get-token get-vals]
:or {get-token identity get-vals identity}})Maps a function of one argument continuously
This is intended to be used with api calls that are paginated to get the full list of results.
Args: f - function of one argument, either nil or a value to be used as a continuation token :get-token - extract the next continuation token from the return value of (f token) :get-vals - extract the values to be returned from the return value of (f token)
Maps a function of one argument continuously This is intended to be used with api calls that are paginated to get the full list of results. Args: f - function of one argument, either nil or a value to be used as a continuation token :get-token - extract the next continuation token from the return value of (f token) :get-vals - extract the values to be returned from the return value of (f token)
(mul-inverse f)Returns a function that returns the multiplicative inverse (1.0/x) of what the input function would return
Returns a function that returns the multiplicative inverse (1.0/x) of what the input function would return
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |