I need to return a sequence, a number and a hash-map from my function (all wrapped in a vector) so that the printed return value looks like this:
[ ([:c :a] [:e :c] [:f :e] [:d :e] [:g :f] [:b :a]) 15
{:g :c, :f :a, :c :e, :d :a, :b :a, :c :a} ]
Since my inputs could be large, I'd like to return lazy sequences/objects from my function. The sequence of pairs (the first object in my return vector) was easy enough to make lazy by wrapping 'lazy-seq' around the conj calls that build it up.
The hash-map (3rd object in my return vector and potentially very large like my sequence) is being built-up (using assoc calls) in the same loop-recur block as the sequence. The hash-map is additional info that some of my callers will use but if the pairs-sequence is returned as lazy then I'm wondering if it makes sense to send back a potentially huge hash-map with (an efficient) lazy-seq even if I make it an optional return-value. The entries in the hash-map are related to the pairs in the lazy-sequence.
So here is my noobie question: Is there any sense in sending back a lazy-sequence of MapEntry's in place of a large HashMap? That is, assuming a user would take a chunk of the lazy-seq of MapEntrys, convert them to hashmap to do a lookup..failing which they'd take the next chunk and so on. Is this a sensible way to lazily use associative-data? Are there some idiomatic ways to return/manage large associative data in Clojure? Would appreciate any ideas as to what my options are. Thanks in advance for your help.