Separate OR AND lookups

Our first pass at a lookup function looks fruitful. We can call it with a number of constraints and get back expected results. However, this function assumes that all our conditions are logical ORs This means a function should satisfy the a OR b OR c condition. But this will satisfy only some of our needs. Often, we'll want more than one constraint to be satisfied at the same time. This is a logical AND. Let's implement this function now. While we're at it, we can refactor our first lookup function and reuse some of its parts:

(defn generate-input-list [constraints] (if (some #{:source} constraints) (let [source-source (comp (partial filter #(= :source (first %1))) (partial partition 2)) source-value (comp second source-source) ...

Get Clojure for Finance now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.