Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>[2*n + 3*m +1 | m &lt;- [0..], n &lt;- [0..]]</code> won't work because it starts with <code>m = 0</code> and goes through all the <code>n</code>, and then has <code>m = 1</code> and goes through all the n, etc. But just the <code>m = 0</code> part is infinite, so you will never get to m = 1 or 2 or 3, etc. So <code>[2*n + 3*m +1 | m &lt;- [0..], n &lt;- [0..]]</code> is exactly the same as <code>[2*n + 3*0 +1 | n &lt;- [0..]]</code>.</p> <p>To generate all of them, you either need to realize, like users vartec and Hynek -Pichi- Vychodil, that the set of numbers you want is just the natural numbers - {0,2}. Or you need to somehow enumerate all the pairs (m,n) such that m,n are nonnegative. One way to do that is to go along each of the "diagonals" where <code>m + n</code> is the same. So we start with the numbers where <code>m + n = 0</code>, and then the ones where <code>m + n = 1</code>, etc. Each of these diagonals has a finite number of pairs, so you will always go on to the next one, and all the pairs (m,n) will eventually be counted.</p> <p>If we let <code>i = m + n</code> and <code>j = m</code>, then <code>[(m, n) | m &lt;- [0..], n &lt;- [0..]]</code> becomes <code>[(j, i - j) | i &lt;- [0..], j &lt;- [0..i]]</code></p> <p>So for you, you can just do</p> <pre><code>[2*(i-j) + 3*j +1 | i &lt;- [0..], j &lt;- [0..i]] </code></pre> <p>(Of course this method will also produce duplicates for you because there are multiple (m,n) pairs that generate the same number in your expression.)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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