[Haskell-begin] Morphing Endo (ICFP Contest 2007)

Rafael Gustavo da Cunha Pereira Pinto rafaelgcpp at gmail.com
Fri Jul 25 22:45:44 EDT 2008


Still on the ICFPC 2007 topic

I am curious about one thing. If I read the file applying hGetContents to a
ByteString (Lazy or Strict) or a String, it seems to read much faster than
the version where I construct a sequence.


    main = do
      (arg1:args)<-getArgs
      hIn <- openFile arg1 ReadMode
      c <-BL.hGetContents hIn               --Really Fast
      let dna =  c
      r<-return (process dna)
      print (show (r))



    main = do
      (arg1:args)<-getArgs
      hIn <- openFile arg1 ReadMode
      c <-hGetContents hIn
      let dna =  fromList c                     --Kind of slow
      r<-return (process dna)
      print (show (r))


I think the "fromList" overhead will be compensated by the O(log(n))
functions on a Seq, against the O(n) counterparts on the strings.


What are your considerations about using Data.Sequence?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20080725/a937c897/attachment.htm


More information about the Beginners mailing list