clojure - How do I write a predicate that checks if a value exists in an infinite seq? -


Today I had an idea for a high-order ceremony that I'm not sure how to write. I have many rare, lazy infinite scenes, and I want to make an abstract which lets me check to see if the given number is in any of these lazy scenes. To improve the performance, I wanted to push the value of the rare sequence in a laughing instrument (or set), whenever there is a need to dynamically increase the number of values ​​in hamsup, due to the sparsity of lazy seqs, MemoNation is not the answer.

The code is probably the easiest to understand, so even what I have so far. How do I change the following code so that the predicate can use a closed-end hessem, but if the size of the size increases, the size increases and redefines itself to use the new hammerpad?

  (defn make-lazy-undoubtedly [cola] "If a number is in coincidence then gives correct or incorrect returns." The call should be sorted, the lazy number must be increased. " In the list? (FN [n call top cache] (if (top n) (not (zero (cash n)) (recur n (next cola) (first time) (cock cash (first call) ))]] (Fn [n] lazy-list (NOC) (first time) (sort-set))) (DF Mary-Lists-List (Repeated # (+% 100) 1)) (Let [My List] (Make-lazy my lazy- Anticipate] Door (in filter-my list? (Limit 10000))  

How do I resolve this problem without returning to a compulsory style?

This is a thread protected by the difference of Adam's solution.

  (defn make- Lazy-predicate [coll] (let [state (atom {: mem # {}: unknown coll}) update-state (fn [{: keys unknown]: items as state] ([[bus check Remaining] (# (& lt; =% item) unknown with partition)] (if (sign bus-check) (-> Raj (ASSOC: MEM (Only Apply Selected Cause Mem)) (ASSOC: Unknown Balance)))) (FN [Item] (Received-in (if (& lt; Item (first (unknown: (@state)) @state (swap! State update-state items)) [: mem items]))))  

using any refs But you can get back through an enclosed transaction with the discovery of your privacy. It may or may be what you want.


Comments