<div style="font-family:Arial; font-size:13px;">Hi,<div><br></div><div>This could gives you for any given integer the list of prime numbers. source is from a stack overflow snippet.</div><div><br></div><div>helper function:</div><div><div>isqrt :: Integral a => a -> a</div><div>isqrt = floor . sqrt . fromIntegral</div></div><div><br></div><div>main function:</div><div><div>primes 1 = []</div><div>primes n = 2:[i | i <- [3,5..n], and [mod i k /= 0 | k <- primes (isqrt i)]]</div><div><br></div><div><br></div><div><br></div><div>my main unclarity is how I should interpret i and k in de mod part. At every step of the recursion.</div><div><br></div><div>example: <i>primes 10</i>.</div><div><br></div><div>it should generate <i><b>[2,3,5,7,9]</b></i> if you ignore the second part.</div><div><br></div><div>however, when I look at the second part</div><div><br></div><div>then first I need to do this <i>primes (isqrt 10)</i>, which give primes 3. which gives met <b style="font-style: italic;">[2,3]</b>. </div><div>first question) I haven't reached base case in this situations so can i or can i not meaningfully evaluate<i> mod i k /= 0</i>?</div><div>Independent of that I now go deeper to reach base case.</div><div>So I go to <i>primes (isqrt 3)</i> which gives me primes 1 which is <b><i>[]</i></b>. Now I hit the base case and need to definitely evaluate <i>mod i k /= 0.</i></div><div>second question) but in this case what is i and what is k?</div><div><br></div><div>If I have it completely wrong, then please be patience. I appreciate the input!</div><div><br></div><div>best,<br><br><div><div style="font-family:Arial; font-size:13px;"><br><br></div></div></div></div></div>