[Haskell-cafe] How to generate random string?
mf-hcafe-15c311f0c at etc-network.de
mf-hcafe-15c311f0c at etc-network.de
Sun Sep 20 09:15:07 EDT 2009
does this compile at all? i don't think i understand the first line.
anyway, a few hints:
- if you want to have all numbers between 0..n in your output for
some n, just in random order, google for "permutation".
- perhaps you can generate the output in an ordered fashion first,
eg. into an array, and then shuffle the list by plucking elements
from it at random into a new list.
- do not use unsafePerformIO. it may reduce the entropy
(randomness) of the results, but even if it doesn't, the code is
prettier without.
good luck! if you get stuck again, just post more code.
matthias
On Fri, Sep 18, 2009 at 10:14:53AM -0700, Snouser wrote:
> To: haskell-cafe at haskell.org
> From: Snouser <linusoleander at gmail.com>
> Date: Fri, 18 Sep 2009 10:14:53 -0700 (PDT)
> Subject: Re: [Haskell-cafe] How to generate random string?
>
>
>
>
> Snouser wrote:
> >
> > I need to generate a random string from 1 to 30.
> >
> > This is the parts I've done so far.
> >
> > unikString xs | let x = unsafePerformIO (randomRIO (1,30)) elem x xs = x :
> > unikString xs
> > | otherwise = unikString xs
> >
> > How do I proceed?
> >
> > I need the string/list to look like this:
> >
> > [1,9,3,6,2] et.c with only unik numbers.
> >
> > Thanks!
> >
>
> I wasnt added to the mailinglist, but now I'm.
>
>
> --
> View this message in context: http://www.nabble.com/How-to-generate-random-string--tp25512293p25512298.html
> Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
> ** ACCEPT: CRM114 PASS osb unique microgroom Matcher **
> CLASSIFY succeeds; success probability: 1.0000 pR: 6.3668
> Best match to file #0 (nonspam.css) prob: 1.0000 pR: 6.3668
> Total features in input file: 2688
> #0 (nonspam.css): features: 758386, hits: 2881904, prob: 1.00e+00, pR: 6.37
> #1 (spam.css): features: 1686754, hits: 3078784, prob: 4.30e-07, pR: -6.37
>
More information about the Haskell-Cafe
mailing list