title: Infinite lazy-sequence of events from external feed
body: <p>Say I have a function, <code>(get-events "feed")</code>, that returns a vector of events in chronological order, taken from an external source.</p>
  
  <p>Now, at any given moment, that function returns a list of events up to that point in time. Called a few seconds later, it will return a few more events, etc, as the feed continually grows.</p>
  
  <p>If I want to create a lazy-seq that forever pulls new events from the feed, making sure it doesn't repeat those that have already been seen, how would I write this? I'm running into a stack overflow error when I don't use <code>recur</code>, but I can't use recur, because it doesn't appear in a tail position.</p>
  
  <pre><code>(def continually-list-events
    ([feed] (continually-list-events feed (hash-set)))
    ([feed seen]
     (let [events-now (get-events feed)]
       (into (remove seen events-now)
             (lazy-seq
               (continually-list-events feed
                                        (into seen events-now))))))
  </code></pre>
  
  <p>You can see I'm trying to use an accumulator to track events already seen (in a set), and I'm making sure to always filter out the ones I've seen.</p>