Hooke your functions!
(defn examine [x] (println x))
(defn microscope "The keen powers of observation enabled by Robert Hooke allow for a closer look at any object!" [f x] (f (.toUpperCase (str x))))
(defn doubler [f & args] (apply f args) (apply f args))
(defn telescope [f x] (f (apply str (interpose " " x))))
(add-hook #'examine #'microscope) (add-hook #'examine #'doubler) (add-hook #'examine #'telescope)
;; Now when we examine something: (examine "something")
S O M E T H I N G S O M E T H I N G
Use the add-hook function to wrap a function in your a hook.
Hooke your functions!
(defn examine [x]
(println x))
(defn microscope
"The keen powers of observation enabled by Robert Hooke allow
for a closer look at any object!"
[f x]
(f (.toUpperCase (str x))))
(defn doubler [f & args]
(apply f args)
(apply f args))
(defn telescope [f x]
(f (apply str (interpose " " x))))
(add-hook #'examine #'microscope)
(add-hook #'examine #'doubler)
(add-hook #'examine #'telescope)
;; Now when we examine something:
(examine "something")
> S O M E T H I N G
> S O M E T H I N G
Use the add-hook function to wrap a function in your a hook.(add-hook target-var f)(add-hook target-var key f)Add a hook function f to target-var. Hook functions are passed the target function and all their arguments and must apply the target to the args if they wish to continue execution.
Add a hook function f to target-var. Hook functions are passed the target function and all their arguments and must apply the target to the args if they wish to continue execution.
(clear-hooks target-var)Remove all hooks from target-var.
Remove all hooks from target-var.
(remove-hook target-var key)Remove hook identified by key from target-var.
Remove hook identified by key from target-var.
(with-scope & body)Defines a scope which records any change to hooks during the dynamic extent of its body, and restores hooks to their original state on exit of the scope.
Defines a scope which records any change to hooks during the dynamic extent of its body, and restores hooks to their original state on exit of the scope.
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 |