[Haskell-cafe] Linear shuffle
Ketil Malde
ketil+haskell at ii.uib.no
Fri Jan 14 04:17:27 EST 2005
Tomasz Zielonka <tomasz.zielonka at gmail.com> writes:
> On Fri, Jan 14, 2005 at 09:17:41AM +0100, Gracjan Polak wrote:
>> This algorithm seems not effective, length, take, drop and (!!) are
>> costly. Is there any better way to implement shuffle?
> You can use mutable arrays (modules Data.Array.MArray, Data.Array.IO).
But is that better, really? IIUC, you will now need to shift the first
part of the string to the right, so it's still a linear operation for
each shuffle.
-kzm
--
If I haven't seen further, it is by standing in the footprints of giants
More information about the Haskell-Cafe
mailing list