Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Short answer: <code>stream-builder</code> returns a function that returns an infinite sequence/list, which must be evaluated 'lazily' (since you can't evaluate something infinitely long in finite time). In the Clojure world, you should probably call none of the things in your example "streams" to avoid confusion with another concept. </p> <p>Longer answer:</p> <p>An unfortunate side effect of the diversity of thought in programming languages is that we often use the same words for different meanings. All three words you mentioned ("Stream", infinite list", "lazy sequence") refer to processing elements in a serial fashion, and in Clojure we call these "Sequences". However, the nuances implied by each are slightly different. </p> <p>A "stream" refers generally to some sequence of elements, and is nowadays often used in the context of finite character sequences. Often these character sequences come from a file, network source, or Unix pipe.</p> <p>If a sequence is defined in a way that it has an infinite number of elements, we can call it an infinite sequence. Usually infinite sequences are represented internally as a <a href="http://en.wikipedia.org/wiki/Linked_list" rel="noreferrer">linked list</a> , so we may call these "infinite lists". Although, to be honest I would prefer to hear the term "infinite sequence" in the Clojure community so we are not tied to a particular implementation.</p> <p>Finally, the nuance of "lazy sequence" in Clojure refers to a pattern of sequential evaluation on a data structure that occurs "on demand". In other words, the emphasis here is on the <em>lazy</em> nature of evaluation; the value of a particular element in the sequence is not actually computed until you ask for it. </p> <p>In summary, in Clojure you should use the words:</p> <ul> <li>"list" to refer to something with a linked list implementation </li> <li>"lazy" to refer to things that evaluate on demand</li> <li>"infinite" to refer to sequences that aren't of finite size (and must therefore be lazy)</li> <li>"stream" to refer to a pipe-like (character) sequence from an external source</li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload