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 = {
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
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
__
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
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
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
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
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
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
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
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
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
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).
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
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
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)
>
> 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
> 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-
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
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
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
=
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
> 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.
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?
___
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
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
> 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.
>
> 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
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
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
30 matches
Mail list logo