[Haskell-beginners] Confused by GLFW and more
Felipe Almeida Lessa
felipe.lessa at gmail.com
Thu Mar 3 18:18:34 CET 2011
On Thu, Mar 3, 2011 at 5:13 PM, Daniel Fischer
<daniel.is.fischer at googlemail.com> wrote:
> On Thursday 03 March 2011 17:40:52, Britt Anderson wrote:
>> This does fix the problem. Thank you. But raises a new question. Since
>> that list was being constructed like this
>>
>> where trialList oldps =
>> [[(h' i) , (p' i)] | i <- [1 ..], i < tn]
>>
>
> where trialList oldps =
> [[h' i, p' i] | i <- takeWhile (< tn) [1 .. ]]
>
> The probem is that the compiler can't know that i never gets smaller than
> tn again once the first i >= tn is reached¹, so it is busy generating ever
> larger integers and testing them against tn, never finishing (well, it will
> finish when i is large enough to blow your memory, perhaps when
> i >= 2^(2^31) on a 32-bit system, I don't know how overflow of Integer is
> handled)
And the fix would be to code as
where trialList oldps =
[[h' i, p' i] | i <- [1..tn]]
PS: Why aren't you using a tuple? =)
--
Felipe.
More information about the Beginners
mailing list