H. <[EMAIL PROTECTED]> writes:

> Hello @ all,
> 
> Sometimes one has an imperative algorithm, and wants to write a program in 
> Haskell which do has the same effect...
> 
> So the question is - how a construct as the following can efficiently be 
> written?
> 
> --
> Pseudo code:
>   n[1..10000] = false
>   for (1..10000) |i|
>     for (i,2*i..10000) |j|
>       n[j] = not n[j]
> --
> 
> Certainly it is in this special case equivalent to (True where the index is):
> map (^2) [1..100]
> 
> But I mean the destructive updates in the imperative code in Haskell without 
> filling the (many times more than in imperative languages) memory with 
> recursively called functions...

The idea in Haskell is not to think of stepping through the
array.  Look at accumArray and ixmap.

-- 
Jón Fairbairn                                 [EMAIL PROTECTED]


_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to