Re: [Haskell-cafe] Speed comparison?

2005-05-04 Thread Gracjan Polak
Daniel Carrera wrote: > Hi all, > > Thank you for all the information on my previous question. I learned a > lot, and good pointers to more info. > > My next question is about speed. How fast would you consider Haskell? > (say, for computational work). How would you compare it to C, Python and > Ru

Re: [Haskell-cafe] Data.Map

2005-04-03 Thread Gracjan Polak
Sebastian Sylvan wrote: On Apr 3, 2005 9:38 AM, Gracjan Polak <[EMAIL PROTECTED]> wrote: insertList asclist map = union map (Data.Map.fromList asclist) How about: insertList :: (Ord a) => Map a b -> [(a, b)] -> Map a b insertList = foldr (uncurry insert) Is there any reason why

[Haskell-cafe] Data.Map

2005-04-02 Thread Gracjan Polak
Hi all, As I tried to convert some of my code to newer libraries comming with GHC 6.4, I would like to share two things with you: I noticed that there are two functions missing: deleteList and insertList. The first one is easy with foldl: deleteList list map = foldl (flip Data.Map.delete) map lis

Re: [Haskell-cafe] hFileSize vs length

2005-03-12 Thread Gracjan Polak
S. Alexander Jacobson wrote: > I am using GHC 6.2 on windows and am finding that when I open a file and > use hFileSize I get a different number than I get from reading in the > file and calculating the length. I assume this is not a bug, but I > don't know why its happening. Isn't that because o

Re: [Haskell-cafe] List manipulation

2005-01-26 Thread Gracjan Polak
Dmitri Pissarenko wrote: > Hello! > > I have two lists of Double with equal length and want to create a third one, > in which each element is the sum of the corresponding element of the first > list and the second list. > > If list1 is [1, 2, 100] and list2 is [2, 3, 500], then the result of the

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 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

[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] Re: Hugs vs GHC (again) was: Re: Somerandomnewbiequestions

2005-01-11 Thread Gracjan Polak
Simon Marlow wrote: > There's a big lock on File. If you want to do truly concurrent reading, > you can make multiple FileInputStreams, each of which has its own file > descriptor (the Unix implementation uses dup(2)). > Original and descriptor returned by dup or dup2 share file pointer. -- Gracj

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

2005-01-11 Thread Gracjan Polak
Marcin 'Qrczak' Kowalczyk wrote: > > "fileRead :: File -> FileOffset -> Integer -> Buffer -> IO ()" > > This is unimplementable safely if the descriptor is read concurrently > by different processes. The current position is shared. > UNIX98 defines function: extern ssize_t pread (int __fd, void *_

<    1   2