title: How to generate a lazy sequence in clojure using non-tail recursion?
body: <p>Take integer partition problem for example, I can write the following code to output all partitions of a positive integer <code>n</code>:</p>
  
  <pre><code>(defn foo
    ([n] (foo n n []))
    ([n k buf]
      (if (zero? n)
        (println buf)
        (doseq [i (range 1 (inc (min n k)))]
          (foo (- n i) i (conj buf i))))))
  </code></pre>
  
  <p>Then <code>(foo 5)</code> outputs:</p>
  
  <pre><code>[1 1 1 1 1]
  [2 1 1 1]
  [2 2 1]
  [3 1 1]
  [3 2]
  [4 1]
  [5]
  </code></pre>
  
  <p>The question is how could I write a function <code>bar</code> which generates a lazy-seq containing such results? For example, I want <code>(bar 5)</code> generates <code>([1 1 1 1 1] [2 1 1 1] [2 2 1] [3 1 1] [3 2] [4 1] [5])</code>.</p>