Re: [Haskell-cafe] Question about instance

2005-01-14 Thread Ketil Malde
John Velman <[EMAIL PROTECTED]> writes: >> data Relation a i b = Rel {name::RN, arity::Int, members::(Set [EN])} Why do you parametrize the data type when you don't use the parameters? Either do data Relation = Rel {name::RN, arity::Int, members::Set [EN]} or data Relation a i b = {

[Haskell-cafe] Linear shuffle

2005-01-14 Thread Gracjan Polak
Hi, I want to implement linear list shuffle in Haskell (http://c2.com/cgi/wiki?LinearShuffle) and I invented code: shuffle :: [a] -> IO [a] shuffle [] = return [] shuffle x = do r <- randomRIO (0::Int,length x - 1) s <- shuffle (take r x ++ drop (r+1) x) return ((x!!r) : s) This algor

Re: [Haskell-cafe] Linear shuffle

2005-01-14 Thread Tomasz Zielonka
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). Best regards, Tomasz __

Re: [Haskell-cafe] Linear shuffle

2005-01-14 Thread Ketil Malde
Gracjan Polak <[EMAIL PROTECTED]> writes: > shuffle :: [a] -> IO [a] > shuffle [] = return [] > shuffle x = do > r <- randomRIO (0::Int,length x - 1) > s <- shuffle (take r x ++ drop (r+1) x) > return ((x!!r) : s) > This algorithm seems not effective, length, take, drop and (!!) a

Re: [Haskell-cafe] Linear shuffle

2005-01-14 Thread Keean Schupke
Gracjan Polak wrote: This algorithm seems not effective, length, take, drop and (!!) are costly. Is there any better way to implement shuffle? Here is an algorithm known as a perfect-shuffle... I am not too sure of the efficiency compared to the example you gave, but it builds a tree to enable

Re: [Haskell-cafe] Linear shuffle

2005-01-14 Thread Ketil Malde
Tomasz Zielonka <[EMAIL PROTECTED]> 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, Da

Re: [Haskell-cafe] Linear shuffle

2005-01-14 Thread Tomasz Zielonka
On Fri, Jan 14, 2005 at 10:17:27AM +0100, Ketil Malde wrote: > Tomasz Zielonka <[EMAIL PROTECTED]> 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 implemen

Re: [Haskell-cafe] Linear shuffle

2005-01-14 Thread Henning Thielemann
On Fri, 14 Jan 2005, Gracjan Polak wrote: > I want to implement linear list shuffle in Haskell > (http://c2.com/cgi/wiki?LinearShuffle) and I invented code: > > shuffle :: [a] -> IO [a] > shuffle [] = return [] > shuffle x = do > r <- randomRIO (0::Int,length x - 1) > s <- shuffle (ta

Re: [Haskell-cafe] Linear shuffle

2005-01-14 Thread Keean Schupke
Please see: http://okmij.org/ftp/Haskell/perfect-shuffle.txt For an explanation of the algorithm. Keean. Ketil Malde wrote: Tomasz Zielonka <[EMAIL PROTECTED]> writes: On Fri, Jan 14, 2005 at 09:17:41AM +0100, Gracjan Polak wrote: This algorithm seems not effective, length, take, drop an

Re: [Haskell-cafe] Linear shuffle

2005-01-14 Thread John Meacham
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? Oleg wrote a great article on implementing the perfect shuffle. with some sample code. http://okmij.org/ftp

Re: [Haskell-cafe] Linear shuffle

2005-01-14 Thread Ketil Malde
Tomasz Zielonka <[EMAIL PROTECTED]> writes: >> 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. > Perhaps I don't know this particular algorithm, but you can shuffle the > array with l

[Haskell-cafe] Introducing me

2005-01-14 Thread fabian otto
Hi, my name is Fabian Otto. I'm doing my master in computer science at the technical university of Berlin (Germany). I have choosen advanced functional programming (FTFP) [1] as one of my subjects. In this course we use opal[2] with some unimplemented features. e.g: * optional laziness * para

Re: [Haskell-cafe] Linear shuffle

2005-01-14 Thread Ketil Malde
Keean Schupke <[EMAIL PROTECTED]> writes: > Please see: http://okmij.org/ftp/Haskell/perfect-shuffle.txt > For an explanation of the algorithm. Right. I was commenting based on the source posted by Gracjan. (And http://c2.com/cgi/wiki?LinearShuffle contains a variety of shuffling algorithms).

Re: [Haskell-cafe] Linear shuffle

2005-01-14 Thread Gracjan Polak
Henning Thielemann wrote: Is it a good idea to use IO monad for this plain computation? It is needed as random number supply. -- Gracjan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Linear shuffle

2005-01-14 Thread Gracjan Polak
John Meacham wrote: > Oleg wrote a great article on implementing the perfect shuffle. with > some sample code. > > http://okmij.org/ftp/Haskell/misc.html#perfect-shuffle > Thats the kind of answer I was hoping to get :) Thanks. shuffle could be useful in standard library. At least Python has it. I

Re: [Haskell-cafe] Linear shuffle

2005-01-14 Thread Daniel Fischer
Am Freitag, 14. Januar 2005 09:50 schrieb Ketil Malde: > Gracjan Polak <[EMAIL PROTECTED]> writes: > > shuffle :: [a] -> IO [a] > > shuffle [] = return [] > > shuffle x = do > > r <- randomRIO (0::Int,length x - 1) > > s <- shuffle (take r x ++ drop (r+1) x) > > return ((x!!r) : s) >

Re: [Haskell-cafe] Re: I/O interface

2005-01-14 Thread Keith Wansbrough
> First of all, I don't think any OS shares file pointers between > processes. Otherwise it would be practically impossible to safely use an > inherited filehandle via any API. Different threads using the same > filehandle do share a file pointer (which is a major nuisance in my > experience, b

Re: [Haskell-cafe] Introducing me

2005-01-14 Thread Keith Wansbrough
> Hi, > > my name is Fabian Otto. Welcome! Feel free to join in the discussion. --KW 8-) -- Keith Wansbrough <[EMAIL PROTECTED]> http://www.cl.cam.ac.uk/users/kw217/ University of Cambridge Computer Laboratory. ___ Haskell-Cafe mailing list Haskell-

Re: [Haskell-cafe] Linear shuffle

2005-01-14 Thread Scott Turner
The shuffling algorithms mentioned so far are comparable to insertion/selection sort. I had come up with a shuffler that relates to quicksort, in that it partitions the input randomly into lists and works recursively from there. It looks efficient and works out well in Haskell. shuffle [] = ret

Re: [Haskell-cafe] Linear shuffle

2005-01-14 Thread Henning Thielemann
On Fri, 14 Jan 2005, Scott Turner wrote: > The shuffling algorithms mentioned so far are comparable to > insertion/selection sort. I had come up with a shuffler that relates to > quicksort, in that it partitions the input randomly into lists and works > recursively from there. It looks efficie

[Haskell-cafe] Matroids in Haskell

2005-01-14 Thread Gerhard Navratil
Recently I had a course on matroids and would like to investigate the topic a little further. Did anybody write (or start writing) a Haskell-implementation for matroids? It would save me some time figuring out if this part of mathematics is useful for my work ... Thanks in advance, Gerhard =

Re: [Haskell-cafe] Linear shuffle

2005-01-14 Thread Marcin 'Qrczak' Kowalczyk
Henning Thielemann <[EMAIL PROTECTED]> writes: > I did some shuffling based on mergesort, that is a list is randomly split > (unzipped) into two lists and the parts are concatenated afterwards. You > must repeat this some times. It even works for infinite lists. I think it doesn't guarantee equal

[Haskell-cafe] Introducing me

2005-01-14 Thread Derek Elkins
> Hi, > > my name is Fabian Otto. Heya. Some other fixtures of the Haskell Community are covered on this page, http://haskell.org/hawiki/HaskellCommunities. Two noteworthy ones are the wiki (http://haskell.org/hawiki/) obviously, and the #haskell IRC channel on irc.freenode.net (http://haskell.

Re: [Haskell-cafe] Matroids in Haskell

2005-01-14 Thread Henning Thielemann
On Fri, 14 Jan 2005, Gerhard Navratil wrote: > Recently I had a course on matroids and would like to investigate the > topic a little further. Did anybody write (or start writing) a > Haskell-implementation for matroids? Do you mean a Matroid type class? ___

Re: [Haskell-cafe] Matroids in Haskell

2005-01-14 Thread Dmitri Pissarenko
Hello! Gerhard Navratil wrote: Recently I had a course on matroids and would like to investigate the topic a little further. Did anybody write (or start writing) a Haskell-implementation for matroids? What is a matroid? Thanks Dmitri Pissarenko -- Dmitri Pissarenko Software Engineer http://dapissar

[Haskell-cafe] Efficiency Question

2005-01-14 Thread Daniel Fischer
Hi folks, toying a bit with splitAt and take, I have met yet another thing, I don't understand. In the Hugs Prelude, splitAt is defined splitAt n xs | n <= 0 = ( [],xs) splitAt _ [] = ([],[]) splitAt n (x:xs)= (x:xs',xs'') where (xs',xs'') = splitAt (n-1) xs whereas in the

Re: [Haskell-cafe] Linear shuffle

2005-01-14 Thread Atwood, John Wesley
> Gracjan Polak <[EMAIL PROTECTED]> wrote: > John Meacham wrote: > > Oleg wrote a great article on implementing the perfect > shuffle. with > > some sample code. > > > > http://okmij.org/ftp/Haskell/misc.html#perfect-shuffle > > > > Thats the kind of answer I was hoping to get :) Thanks. >

Re: [Haskell-cafe] Problem with wxHaskell

2005-01-14 Thread Atwood, John Wesley
> Jinwoo Lee <[EMAIL PROTECTED]> > You can remove that error message by including following in > package.conf file. > > Package >{name = "readline", > auto = True, > import_dirs = ["$libdir/imports"], > source_dirs = [], > library_dirs = ["$libdir"], > hs_libraries = ["HSr

Re: [Haskell-cafe] Efficiency Question

2005-01-14 Thread Tom Pledger
Daniel Fischer wrote: [snip] Another thing, while toying, I found out that a comparison (n <= 0) takes three reductions more than (n < 1) according to my hugs, so changing the definition of splitAt thus, we require (3*n) reductions less. That difference looks like it comes from the default defin

Re: [Haskell-cafe] Re: Hugs vs GHC (again)was: Re: Somerandomnewbiequestions

2005-01-14 Thread John Meacham
On Wed, Jan 12, 2005 at 12:21:25AM +, Aaron Denney wrote: > On 2005-01-11, Simon Marlow <[EMAIL PROTECTED]> wrote: > > On 11 January 2005 14:15, Gracjan Polak wrote: > > > >> Simon Marlow wrote: > >> > There's a big lock on File. If you want to do truly concurrent > >> reading, > you can mak