Hot answers tagged

2

I'd never thought of using reduce for this. Neat! However, you can simplify mk-balanced? a little. str->chars is redundant: reduce and the other sequence functions accept strings as such. You can use reduced to short circuit a reduce. The reduced can return any non-empty sequence: no need for [:false]. The simplified version is ... (defn mk-balanced? [...


2

We want to exclude from the vector (more generally a sequence) the maps of which any map in the blacklist is a sub-map. Let's define a function that tests whether its first argument is a sub-map of its second argument: (defn submap? [a b] (every? (fn [[k v]] (= v (b k))) a)) For instance, => (map #(submap? {1 2} %) [{} {1 1} {1 2}]) (false false ...


Only top voted, non community-wiki answers of a minimum length are eligible