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 +
Here is my post from the ffi mail list and some comments. Although not
directly related to your question, I believe this whole issue merits further
discussion, which unfortunately did not ensue with my post on the ffi mail
list. And indeed from time to time it does seem to pop-up. I guess it is
[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.
At 08:25 06/03/2003 +0100, Johannes Waldmann wrote:
On Wed, 5 Mar 2003, Graham Klyne wrote:
> I've released a first version of some URI parsing and handling code at:
>http://www.ninebynine.org./Software/HaskellURI.zip
but this library is already in ghc:
http://www.haskell.org/ghc/docs/latest/h
Hi all,
I'm looking for some kind of style-guide for layout and indentation of haskell
source code, can anyone help me?
Thanks, Per
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell
Hello,
I am currently toying with the idea of implementing a PostScript
library in Haskell, and I am currently implementing a static,
simplified version of the Postscript type checker using phantom types
and functional dependencies. I am enriching the Postscript definitions
with types so that
> 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) : pe
> Oops. I didn't find that. Thanks for the pointer. (Thinks:
> does it work with HUGS?)
It works with the latest hugs, November 2002 (use "hugs +N" to get the
hierarchical libraries).
> A significant amount of my work went into the test cases and
> matching the
> parsing code against the (
Please can you publicise this amongst your colleagues and particularly
PhD students who could take advantage of our grants for accommodation
etc
+-+
CALL FOR PARTICIPATION
Briti
> a recent post reminded me of a feature i'd like.
> for all i know it is already implemenetd in GHC so pointers
> are welcome.
>
> i'd like to be able to dump data structures to disk, and later load
> them.
A Binary library was discussed recently on the libraries list. The
thread starts here
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 :: (
Per Larsson <[EMAIL PROTECTED]> writes:
> I'm looking for some kind of style-guide for layout and indentation of haskell
> source code, can anyone help me?
There are various pretty-printing libraries for Haskell, for example:
http://www.haskell.org/ghc/docs/latest/html/haskell-src/Language.Hask
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.
>
>pe
> There are various pretty-printing libraries for Haskell, for example:
Yeah, but that's only half the job. You have to combine these with a Haskell
parser in order to get a program with the functionality of (say) 'indent'
(or have I misunderstood what the libraries do?)
I though this was quite g
hmake-3.07
--
http://www.haskell.org/hmake
We announce a new release, 3.07, of hmake, the automatic compilation
manager for Haskell programs. This fresh version has the following
improved configuration features over previous
[EMAIL PROTECTED] wrote:
> Is there a library routine for random permutations?
Check out this link:
http://www.nist.gov/dads/HTML/perfectShuffle.html
--
Matthew Donadio ([EMAIL PROTECTED])
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.
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 $ \_ _
Hi All,
I have a data type defined as
> data D a = D1 Int | D2 a
Follow this definition, I have D2 Int,D2 Bool and D2 [D2 Int] as instances
of type D.
I want to write an overloaded function lift which lifts an atom type to D.
It is easily done for D2 Int and D2 Bool using type classes.I can h
--- George Russell <[EMAIL PROTECTED]> wrote:
> I think Ralf Hinze's method is the best presented so far. I would
> write
> it slightly differently though. In pseudo-code I would proceed as
> follows:
> (1) write the values to an array a[1]..a[n]
> (2) for i from n to 2
> do
>j <- ra
[EMAIL PROTECTED] wrote:
> > I agree with what you said,
> > but I think you may have missed my point.
>
> Sounds likely on both counts.
Probably. I get confused a lot. :)
> So now I have to say ...
>
>denominator $ fromInteger (floor (23 % 45))
>
> Is this the same malarkey that you are
> 1. Generate N random numbers r_k, say, uniform between 0 and 1.
> 2. Form N pairs (1,r_1), (2,r_2), (3, r_3) ... (N,r_n).
> 3. Sort this list/vector wrt the *secon* (random) number.
> 4. In the sorted list the firs values (indices) give you the result.
> This is of course quite general, not res
Johannes Waldmann <[EMAIL PROTECTED]> writes:
> Dear all, I am looking for a Haskell library for the HTTP/1.1 protocol,
> i. e. data types for Requests and Responses,
> and functions to read chunked bodies etc. Is there such a thing?
Warrick Gray wrote a small HTTP library. You can find it at:
There seems to be a mismatch between hugs and ghc.
hugs -98
:version
-- Hugs Version February 2001
accepts the following:
== EqList.hs
module EqList where
data Nil = Nil
data Cons x xs = Cons x xs
class EqList a b c | a b -> c where
comp :: a -> b -> c
comp _ _ = error
Hello.
I think I've come across a GHCi bug.
Using the following module, GHCi version 5.04.2 segfaults, apparently
trying to compute a type using functional dependencies. The segfault
happens when I try to calculate (v1 .> v2). I tried the code on Hugs,
and it answers
Main> v1 .> v2
V [] :: PSOp
[EMAIL PROTECTED] comments my suggestion:
1. Generate N random numbers r_k, say, uniform between 0 and 1.
2. Form N pairs (1,r_1), (2,r_2), (3, r_3) ... (N,r_n).
3. Sort this list/vector wrt the *second* (random) number.
4. In the sorted list the first values (indices) give you the result.
I'm so
25 matches
Mail list logo