walkmap.utils
Miscellaneous utility functions.
=ish
(=ish n1 n2)(=ish n1 n2 tolerance)True if numbers n1, n2 are roughly equal; that is to say, equal to within tolerance (defaults to one part in one hundred thousand).
check-kind-type
macro
(check-kind-type object expected)(check-kind-type object checkfn expected)If object is not of kind-type expected, throws an IllegalArgumentException with an appropriate message; otherwise, returns object. If checkfn is supplied, it should be a function which tests whether the object is of the expected kind-type.
Macro, so that the exception is thrown from the calling function.
check-kind-type-seq
macro
(check-kind-type-seq s expected)(check-kind-type-seq s checkfn expected)If some item on sequence s is not of the expected kind-type, throws an IllegalArgumentException with an appropriate message; otherwise, returns object. If checkfn is supplied, it should be a function which tests whether the object is of the expected kind-type.
Macro, so that the exception is thrown from the calling function.
deep-merge
(deep-merge & vals)Recursively merges maps. If vals are not maps, the last value wins.
kind-type
(kind-type object)Identify the type of an object, e.g. for logging. If it has a :kind key, it’s one of ours, and that’s what we want. Otherwise, we want its type; but the type of nil is nil, which doesn’t get printed when assembling error ,essages, so return “nil”.
truncate
(truncate s n)If string s is more than n characters long, return the first n characters; otherwise, return s.