futils library, utility functions.
futils library, utility functions.
(any? pred coll)
Returns true if the given collection (coll) contains at least one element for which a value passed as the pred argument is not false and not nil.
Returns true if the given collection (coll) contains at least one element for which a value passed as the pred argument is not false and not nil.
(count-first coll)
Counts elements of a collection which is the first element of a given collection.
Counts elements of a collection which is the first element of a given collection.
(frepeat f)
(frepeat f kvs)
(frepeat n f)
(frepeat n f kvs)
Returns a lazy sequence of results produced by the given function f which should accept named arguments.
If the first argument passed to frepeat is a number and the second is a function it will limit the iterations to the specified count. If the numeric argument is missing and only a function object is given the frepeat will produce infinite sequence of calls.
The last, optional argument should be a map that initializes named arguments that will be passed to the first and subsequent calls to f.
Additionally each call to f will pass the following keyword arguments:
:iteration – a number of current iteration (starting from 1), :previous – a result of the previous call to f.
The first call to f will pass the following:
:iteration – 1, :iterations – a total number of iterations (if nr was given).
It is possible to set the initial value of :previous if there is a need for that (by passing it to frepeat) or shadow the :iterations after the first call (by setting it in the passed function f).
Values associated with :iteration and :previous keys will always change during each call.
Returns a lazy sequence of results produced by the given function f which should accept named arguments. If the first argument passed to frepeat is a number and the second is a function it will limit the iterations to the specified count. If the numeric argument is missing and only a function object is given the frepeat will produce infinite sequence of calls. The last, optional argument should be a map that initializes named arguments that will be passed to the first and subsequent calls to f. Additionally each call to f will pass the following keyword arguments: :iteration – a number of current iteration (starting from 1), :previous – a result of the previous call to f. The first call to f will pass the following: :iteration – 1, :iterations – a total number of iterations (if nr was given). It is possible to set the initial value of :previous if there is a need for that (by passing it to frepeat) or shadow the :iterations after the first call (by setting it in the passed function f). Values associated with :iteration and :previous keys will always change during each call.
(mapply f & args)
Like apply but works on named arguments. Takes function f and a list of arguments to be passed, were the last argument should be a map that will be decomposed and passed as named arguments.
Returns the result of calling f.
Like apply but works on named arguments. Takes function f and a list of arguments to be passed, were the last argument should be a map that will be decomposed and passed as named arguments. Returns the result of calling f.
(method-argc m)
Returns the number of arguments Java method takes.
Returns the number of arguments Java method takes.
(method-name m)
Returns the name of the given Java method.
Returns the name of the given Java method.
(nearest-right s v)
For the given sorted set of integer values and the given value returns the closest value from the set, picking up the highest one in case of no exact match.
For the given sorted set of integer values and the given value returns the closest value from the set, picking up the highest one in case of no exact match.
(non-negative n)
Ensures that a given value is positive or 0. If it's negative it returns 0.
Ensures that a given value is positive or 0. If it's negative it returns 0.
(pos- x y)
Like - operator but works for 2 numbers and never returns negative values. If value is negative, it will return 0.
Like - operator but works for 2 numbers and never returns negative values. If value is negative, it will return 0.
(pred-as-> expr name pred & forms)
Binds name to expr, evaluates the first form in the lexical context of that binding, then binds name to that result, repeating for each successive form, returning the result of the last form or nil if the pred called with current value of name returns false or nil (in this case successive forms are not evaluated).
Binds name to expr, evaluates the first form in the lexical context of that binding, then binds name to that result, repeating for each successive form, returning the result of the last form or nil if the pred called with current value of name returns false or nil (in this case successive forms are not evaluated).
(some-as-> expr name & forms)
Binds name to expr, evaluates the first form in the lexical context of that binding, then binds name to that result, repeating for each successive form, returning the result of the last form or nil if one of the forms evaluates to nil (in this case successive forms are not evaluated).
Binds name to expr, evaluates the first form in the lexical context of that binding, then binds name to that result, repeating for each successive form, returning the result of the last form or nil if one of the forms evaluates to nil (in this case successive forms are not evaluated).
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close