title: Writing infinite list to skip every factor of p?
body: <p>How can I efficiently represent the list <code>[0..] \\ [t+0*p, t+1*p ..]</code>?</p>
  
  <p>I have defined:</p>
  
  <pre><code>Prelude&gt; let factors p t = [t+0*p, t+1*p ..]
  </code></pre>
  
  <p>I want to efficiently represent an infinite list that is the difference of <code>[0..]</code> and <code>factors p t</code>, but using <code>\\</code> from <a href="http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data-List.html" rel="nofollow"><code>Data.List</code></a> requires too much memory for even medium-sized lists:</p>
  
  <pre><code>Prelude Data.List&gt; [0..10000] \\ (factors 5 0)
  &lt;interactive&gt;: out of memory
  </code></pre>
  
  <p>I know that I can represent the values between <code>t+0*p</code> and <code>t+1*p</code> with:</p>
  
  <pre><code>Prelude&gt; let innerList p1 p2 t = [t+p1+1, t+p1+2 .. t+p2-1]
  Prelude&gt; innerList 0 5 0
  [1,2,3,4]
  </code></pre>
  
  <p>However, repeatedly calculating and concatenating <code>innerList</code> for increasing intervals seems clumsy.</p>
  
  <p>Can I efficiently represent <code>[0..] \\ (factors p t)</code> without calculating <code>rem</code> or <code>mod</code> for each element?</p>