io.randomseed.bankster.util
added in 1.0.0
Support functions and macros.
auto-alias
macro
added in 2.2.0
(auto-alias source-ns)Creates aliases in the current namespace for all Vars in source-ns that have truthy :auto-alias metadata, skipping symbols already defined.
char-ranges->set
added in 1.0.0
(char-ranges->set & ranges)Returns a set of characters defined as a collection of collections with start and stop character, e.g.: \A \Z
gen-digits
added in 1.0.0
(gen-digits num)(gen-digits num rng)Generates the given number of random digits and converts all into a single string. When a second argument is present, it should be an instance of a random number generator used to get the digits.
get-rand-int
added in 1.0.0
(get-rand-int n)(get-rand-int n rng)Like rand-int but optionally uses random number generator.
get-rand-nth
added in 1.0.0
(get-rand-nth v)(get-rand-nth v rng)Returns a random element of the given vector. When a second argument is present, it should be an instance of a random number generator used to get the random position.
inferred-contains?
added in 1.0.0
(inferred-contains? coll k)Just like the contains? but if the keyword is namespace-qualified it also checks if the collection contains the same keyword as its key but without a namespace.
inferred-get
added in 1.0.0
(inferred-get coll k)(inferred-get coll k default)Just like the get function but if the keyword is namespace-qualified it first attempts to look for the value associated with it. If that fails it uses the variant of the keyword without any namespace.
keep-in-set-where
added in 2.0.0
(keep-in-set-where pred s)Returns a set with all elements not matching pred removed.
Returns nil when s is nil or when the resulting set is empty.
lazy-iterator-seq
added in 1.0.0
(lazy-iterator-seq coll)(lazy-iterator-seq coll iter)Returns a lazy sequence as an interface to the given iterable Java object.
ns-infer
added in 1.0.0
(ns-infer ns-name k)(ns-infer ns-name k use-infer)Takes a string of namespace name and a keyword. If the given keyword is not namespace-qualified it returns a new keyword with the given namespace added. If the given keyword is already equipped with a namespace it returns it.
random-digits-len
added in 1.0.0
(random-digits-len x iteration shrink-now)(random-digits-len x iteration shrink-now rng)For 0 or 1 it returns its argument. For other positive numbers it returns a random natural number from 1 to this number (inclusive) in 50% cases. In other 50% cases it returns its argument.
remove-from-set-where
added in 2.0.0
(remove-from-set-where pred s)Returns a set with all elements matching pred removed.
Returns nil when s is nil or when the resulting set is empty.
split-on-first-slash
added in 2.0.0
(split-on-first-slash s)Splits a string on the first slash character (‘/’).
Returns a vector of two strings: [before after]. When s is nil or empty, returns [nil nil]. When there is no slash, returns [s nil]. Uses Java indexOf and substring.
split-on-last-slash
added in 2.2.3
(split-on-last-slash s)Splits a string on the last slash character (‘/’).
Returns a vector of two strings: [before after]. When s is nil or empty, returns [nil nil]. When there is no slash, returns [nil s]. Uses Java lastIndexOf and substring.
try-null
macro
added in 1.0.0
(try-null & body)Evaluates body and if a NullPointerException is caught it returns nil. Otherwise it returns the value of the last expression in the body.
try-parse-int
(try-parse-int s)Returns an integer from an object or nil if the given object cannot be converted to an integer.
try-parse-long
(try-parse-long s)Returns a long from an object or nil if the given object cannot be converted to a long.
when-not-empty
macro
added in 1.0.0
(when-not-empty val & body)Evaluates body when the given value is a non-empty collection.
with-not-empty
added in 1.0.0
(with-not-empty obj)Returns the collection if it’s not empty. Otherwise returns nil.