(build-clauses-from-range domain-bound-symbols range result-sym)
The strategy: In general, maintain a volatile reference to the result.
If the range is a vector/set, the result will be a transient []/#{}.
At each leaf, evaluate the range and 'vswap! into!' it into the maintained result.
At the end of the fn, just call persistent! on the result.
You might think the volatile ref is extraneous since we're using transients, but
fns like conj!
are meant to be used for the result they return, not for their side-effects.
(This caused a weird bug.)
If the range is a map, then the result is a persistent map. Initially, I had created functions like assoc-in! and update-in! that worked on nested map transients, but found that these were actually slower than just merging a bunch of small persistent maps together. I'm not really sure why this was the case. Anyway, at each leaf, evaluate the range and deep merge it into the result. At the end, just return the result.
The strategy: In general, maintain a volatile reference to the result. If the range is a vector/set, the result will be a transient []/#{}. At each leaf, evaluate the range and 'vswap! into!' it into the maintained result. At the end of the fn, just call persistent! on the result. You might think the volatile ref is extraneous since we're using transients, but fns like `conj!` are meant to be used for the result they return, not for their side-effects. (This caused a weird bug.) If the range is a map, then the result is a persistent map. Initially, I had created functions like assoc-in! and update-in! that worked on nested map transients, but found that these were actually slower than just merging a bunch of small persistent maps together. I'm not really sure why this was the case. Anyway, at each leaf, evaluate the range and deep merge it into the result. At the end, just return the result.
(eval-reduce-data reduce-data)
Now that the reducedata's substructures are fully built, apply the reducing functions to them.
Now that the reducedata's substructures are fully built, apply the reducing functions to them.
(reducable-substructures domain-bound-symbols form)
Find the topmost child forms that use collections built in the transform.
For example, if we have (max (apply max [g1]) (apply max [g2])) and both g1 and g2 are domain-bound, then this returns [[g1] [g2]].
By replacing these substructures with gensyms, we get the reducing fn: (fn [g1-sym g2-sym] (max (apply max g1-sym) (apply max g2-sym)))
(see build-reducer).
Find the topmost child forms that use collections built in the transform. For example, if we have (max (apply max [g1]) (apply max [g2])) and both g1 and g2 are domain-bound, then this returns [[g1] [g2]]. By replacing these substructures with gensyms, we get the reducing fn: (fn [g1-sym g2-sym] (max (apply max g1-sym) (apply max g2-sym))) (see build-reducer).
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close