hidden-markov-music.util
assert-args
macro
(assert-args & pairs)
Takes any number of [boolean message]
pairs, and raises an exception with the given message for the first false
boolean.
Taken from clojure.core
, where it is private.
file-extension
(file-extension file-name)
Returns the extension for the given filename, or nil if there is none.
map-for
macro
(map-for seq-exprs body-expr)
Map comprehension. Takes a vector of one or more binding-form/collection-expr pairs, and returns a nested map of collection-expr values to body-expr. Meant as a shorthand for using zipmap
and for
with the same collection. See examples below:
``` (let [xvals (range 3) yvals (range 4 7)] (zipmap xvals (for [x xvals] (* x x))) ;;=> {2 4, 1 1, 0 0} (map-for [x xvals] (* x x)) ;;=> {2 4, 1 1, 0 0}
(zipmap xvals (for [x xvals] (zipmap yvals (for [y yvals] (* x y))))) ;;=> {2 {6 12, 5 10, 4 8}, 1 {6 6, 5 5, 4 4}, 0 {6 0, 5 0, 4 0}} (map-for [x xvals y yvals] (* x y)) ;;=> {2 {6 12, 5 10, 4 8}, 1 {6 6, 5 5, 4 4}, 0 {6 0, 5 0, 4 0}} )
map-vals
(map-vals f m)
Maps a function f
over the values of the map m
, returning a new map.
maps-almost-equal?
(maps-almost-equal? x y & {:keys [decimal], :or {decimal 6}})
Returns true if two numeric (potentially nested) maps are equal to the given decimal place.
numbers-almost-equal?
(numbers-almost-equal? x y & {:keys [decimal], :or {decimal 6}})
Returns true if two numbers are equal to the given decimal place