io.randomseed.bankster.util

added in 1.0.0

Support functions and macros.

bytes-concat

(bytes-concat)(bytes-concat bary)(bytes-concat bary & byte-arys)

bytes-to-string

(bytes-to-string b)

Converts bytes into a string

bzero

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

count-digits

added in 1.0.0

(count-digits n)

current-thread

(current-thread)

current-thread-id

(current-thread-id)

current-thread-name

(current-thread-name)

ensure-keyword

(ensure-keyword id)

ensure-keyword-having-ns

(ensure-keyword-having-ns id ns)

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 the second argument is present it should be an instance of 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 the second argument is present it should be an instance of 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.

is

macro

(is pred val & body)

is-not

macro

(is-not pred val & body)

juxt-seq

(juxt-seq & functions)

Like juxt but returns a lazy sequence.

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.

must-have-ns

(must-have-ns id ns)

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.

replace-in-set

(replace-in-set s old-val new-val)

some-string

(some-string s)

text-to-bytes

(text-to-bytes t)

to-bytes

(to-bytes obj)

to-long

(to-long s default)

try-null

macro

added in 1.0.0

(try-null & body)

Evaluates body and if NullPointerException exception is caught it returns nil. Otherwise it returns the value of last expression in the body.

try-parse-int

(try-parse-int s)

Returns integer from an object or nil if the given object does not contain valid integer.

try-parse-long

(try-parse-long s)

Returns long from an object or nil if the given object does not contain valid long.

try-upper-case

(try-upper-case s)

uuid

(uuid s)

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.