Random Permutations

2003-03-06 Thread Markus . Schnell
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 +

Re: Persistant (as in on disk) data

2003-03-06 Thread mike V
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

Re: Random Permutations

2003-03-06 Thread Jerzy Karczmarczuk
[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.

Re: URI handling code in Haskell available

2003-03-06 Thread Graham Klyne
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

source layout

2003-03-06 Thread Per Larsson
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

Fundeps question

2003-03-06 Thread Carlos Eduardo Scheidegger
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

Re: Random Permutations

2003-03-06 Thread Ralf Hinze
> 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

RE: URI handling code in Haskell available

2003-03-06 Thread Simon Marlow
> 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 (

BCTCS 19

2003-03-06 Thread N Ghani
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

RE: Persistant (as in on disk) data

2003-03-06 Thread Simon Marlow
> 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

Re: Random Permutations

2003-03-06 Thread Andreas Abel
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 :: (

Re: source layout

2003-03-06 Thread shae
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

Re: Random Permutations

2003-03-06 Thread Janis Voigtlaender
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

RE: source layout

2003-03-06 Thread Bayley, Alistair
> 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

ANNOUNCE: hmake-3.07

2003-03-06 Thread Malcolm Wallace
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

Re: Random Permutations

2003-03-06 Thread Matthew Donadio
[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.

Re: random permutations

2003-03-06 Thread George Russell
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 $ \_ _

overload lift function

2003-03-06 Thread Wang Meng
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

Re: random permutations

2003-03-06 Thread Dimitre Novatchev
--- 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

Re: int to float problem

2003-03-06 Thread Matthew Donadio
[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

Re: Random Permutations

2003-03-06 Thread oleg
> 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

Re: HTTP protocol libraries

2003-03-06 Thread Jens Petersen
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:

Fundeps question

2003-03-06 Thread Martin Sulzmann
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

GHCi 5.04.2 segfaults on expression evaluation

2003-03-06 Thread Carlos Eduardo Scheidegger
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

Re: Random Permutations

2003-03-06 Thread Jerzy Karczmarczuk
[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