global registry for memoize functions
global registry for memoize functions
(defmemoize name doc? attrs? & body)defines a cached function
(defmemoize -dec- "decrements" {:added "1.0"} ([x] (dec x)))
(-dec- 1) => 0 @+-dec- => '{(1) 0}
defines a cached function
(defmemoize -dec-
"decrements"
{:added "1.0"}
([x] (dec x)))
(-dec- 1) => 0
@+-dec- => '{(1) 0}(deregister-memoize mem)(deregister-memoize mem var registry)deregisters the memoize function
(deregister-memoize -inc-)
deregisters the memoize function (deregister-memoize -inc-)
(invoke-intern-memoize _ name {:keys [function cache] :as config} body)creates a memoize form template for definvoke
(invoke-intern-memoize :memoize 'hello {} '([x] x))
creates a memoize form template for `definvoke`
(invoke-intern-memoize :memoize 'hello {} '([x] x))(memoize function cache var)(memoize function cache var registry status)caches the result of a function (ns-unmap ns '+-inc-) (ns-unmap ns '-inc-) (def +-inc- (atom {})) (declare -inc-) (def -inc- (memoize inc +-inc- #'-inc-))
(-inc- 1) => 2 (-inc- 2) => 3
caches the result of a function
(ns-unmap *ns* '+-inc-)
(ns-unmap *ns* '-inc-)
(def +-inc- (atom {}))
(declare -inc-)
(def -inc- (memoize inc +-inc- #'-inc-))
(-inc- 1) => 2
(-inc- 2) => 3(memoize-clear mem)clears all results
(memoize-clear -inc-) => '{(2) 3}
clears all results
(memoize-clear -inc-)
=> '{(2) 3}(memoize-disable mem)disables the usage of the cache
@(memoize-disable -inc-) => :disabled
disables the usage of the cache @(memoize-disable -inc-) => :disabled
(memoize-disabled? mem)checks if the memoized function is disabled
(memoize-disabled? -inc-) => true
checks if the memoized function is disabled (memoize-disabled? -inc-) => true
(memoize-display mem)formats the memoize object
(def +-plus- (atom {})) (declare -plus-) (def -plus- (memoize + +-plus- #'-plus-)) (memoize-display -plus-) => (contains {:status :enabled, :registered false, :items number?}) ;; {:fn +, :cache #atom {(1 1) 2}}
formats the memoize object
(def +-plus- (atom {}))
(declare -plus-)
(def -plus- (memoize + +-plus- #'-plus-))
(memoize-display -plus-)
=> (contains {:status :enabled, :registered false, :items number?})
;; {:fn +, :cache #atom {(1 1) 2}}
(memoize-enable mem)enables the usage of the cache
@(memoize-enable -inc-) => :enabled
enables the usage of the cache @(memoize-enable -inc-) => :enabled
(memoize-enabled? mem)checks if the memoized function is disabled
(memoize-enabled? -inc-) => true
checks if the memoized function is disabled (memoize-enabled? -inc-) => true
(memoize-invoke mem & args)invokes the function with arguments
(memoize-invoke -plus- 1 2 3) => 6
invokes the function with arguments (memoize-invoke -plus- 1 2 3) => 6
(memoize-remove mem & args)removes a cached result
(memoize-remove -inc- 1) => 2
removes a cached result (memoize-remove -inc- 1) => 2
(memoize-status mem)returns the status of the object
(memoize-status -inc-) => :enabled
returns the status of the object (memoize-status -inc-) => :enabled
(register-memoize mem)(register-memoize mem var registry)registers the memoize function
(register-memoize -inc-)
registers the memoize function (register-memoize -inc-)
(registered-memoize? mem)checks if a memoize function is registered
(registered-memoize? -mem-) => false
checks if a memoize function is registered (registered-memoize? -mem-) => false
(registered-memoizes)(registered-memoizes status)(registered-memoizes status registry)lists all registered memoizes
(registered-memoizes)
lists all registered memoizes (registered-memoizes)
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 |