[EMAIL PROTECTED] wrote:
Is there a library routine for random permutations?
I didn't find any and did a quick hack...
There are many algorithms.
One, quite natural and quite fast
(n log n; slower than linear, though...)
consists in:
1. Generate N random numbers r_k, say, uniform between 0 and 1.
Is there a library routine for random permutations?
I didn't find any and did a quick hack, which works fine for my
application (length of list 100), but what would be a more
elegant way?
permute :: StdGen - [a] - [a]
permute gen [] = []
permute gen xs = (head tl) : permute gen' (hd
Is there a library routine for random permutations?
I didn't find any and did a quick hack, which works fine for my
application (length of list 100), but what would be a more
elegant way?
Well, sorting is a special case of permuting, so my idea was to use the library
routine
List.sortBy ::
Andreas Abel wrote:
Well, sorting is a special case of permuting, so my idea was to use the library
routine
List.sortBy :: (a - a - Ordering) - [a] - [a]
passing it a comparison function which ignores its arguments and simply returns
a random bit when invoked, e.g.
permute =
Andreas wrote
Well, sorting is a special case of permuting, so my idea was to use the library
routine
List.sortBy :: (a - a - Ordering) - [a] - [a]
passing it a comparison function which ignores its arguments and simply returns
a random bit when invoked, e.g.
permute = sortBy $ \_ _ -