Core helper functions.
Core helper functions.
(fargs & args)Return a function that takes a fn f yielding (apply f args). While partial is left-associative, fargs is right-associative.
Return a function that takes a fn f yielding (apply f args). While partial is left-associative, fargs is right-associative.
(fixpoint f data-in)Repeatedly call f with data-in until f(data-in) equals data-in.
Repeatedly call f with data-in until f(data-in) equals data-in.
(if-all-let bindings then)(if-all-let bindings then else & oldform)Similar to if-let but supports multiple binding terms which have to be true for the binding evaluation to continue.
Example: (if-all-let [a 1 b (dec a) c (pos? b)] [a b c] "failed") ;=> "failed"
Similar to if-let but supports multiple binding terms which have to be true
for the binding evaluation to continue.
Example:
(if-all-let [a 1
b (dec a)
c (pos? b)]
[a b c]
"failed") ;=> "failed"(ignorantly & exprs)Execute f and return its result. In case an exception is thrown, catch it and return nil.
Execute f and return its result. In case an exception is thrown, catch it and return nil.
(keep-if x pre)(keep-if x pre f)(keep-if x pre f post)Verify that (pre x) is true and return x, otherwise nil. If f is given, return (f x). If post is given, verify that (post (f x)) is true and return (f x), otherwise nil.
Example: (keep-if 5 even?) ;=> 5 (keep-if 5 even? dec) ;=> 4 (keep-if 5 even? dec even?) ;=> nil
Verify that (pre x) is true and return x, otherwise nil. If f is given, return (f x). If post is given, verify that (post (f x)) is true and return (f x), otherwise nil. Example: (keep-if 5 even?) ;=> 5 (keep-if 5 even? dec) ;=> 4 (keep-if 5 even? dec even?) ;=> nil
(lazy & exprs)Return a lazy sequence of the passed-in expressions. Each will be evaluated only if necessary.
Return a lazy sequence of the passed-in expressions. Each will be evaluated only if necessary.
(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)))(unless test body)Same as if, but with negated predicate check.
Same as if, but with negated predicate check.
(verify x test-f f)Verify that (test-f x) is true and return x, otherwise return (f x).
Example: (verify 1 vector? vector) ;=> [1] (verify [1] vector? vector) ;=> [1]
Verify that (test-f x) is true and return x, otherwise return (f x). Example: (verify 1 vector? vector) ;=> [1] (verify [1] vector? vector) ;=> [1]
(when-all-let bindings & body)Similar to when-let but supports multiple binding terms which have to be true for the binding evaluation to continue. Same as if-all-let without the else case.
Example: (when-all-let [a 2 b (dec a) c (pos? b)] [a b c]) ;=> [2 1 true]
Similar to when-let but supports multiple binding terms which have to be true
for the binding evaluation to continue. Same as if-all-let without the else case.
Example:
(when-all-let [a 2
b (dec a)
c (pos? b)]
[a b c]) ;=> [2 1 true]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 |