Re: [Haskell-cafe] (no subject)

2009-08-22 Thread Luke Palmer
On Fri, Aug 21, 2009 at 7:03 PM, Sebastian Sylvansebastian.syl...@gmail.com wrote: I think that there must be standard function that can do this. What do experienced Haskellers use? I usually just whip up a quick parser using Text.ParserCombinators.Parsec I usually prefer ReadP for quick

[Haskell-cafe] Is logBase right?

2009-08-22 Thread Roberto
Hi, There is a mistake is logBase: $ ghci GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. Prelude logBase 10 10 1.0 Prelude logBase 10 100 2.0

Re: [Haskell-cafe] Re: Is logBase right?

2009-08-22 Thread Eugene Kirpichov
2009/8/22 Roberto López plasterm...@hotmail.com: If 4.0 / 2.0 was 1.98, it would be ok? I think yes. However, hardware can afford to do computations as accurately as possible, whereas software like Haskell Prelude can't. The real value of log10 1000 is 3 (3.0). It can be

Re: [Haskell-cafe] Help starting a Haskell blog

2009-08-22 Thread Gwern Branwen
On Sat, Aug 22, 2009 at 6:35 AM, Peter Verswyvelenbugf...@gmail.com wrote: I'm going start my very first blog, documenting my everyday struggle to switch my old imperative mind to the lazy functional setting, with a focus on FRP. Although you can find a lot of articles that provide help to get

Re: [Haskell-cafe] Help starting a Haskell blog

2009-08-22 Thread Peter Verswyvelen
Thanks. At first sight gitit requires that I setup my own server. Although this has advantages and I did that in the past, I prefer to use a public server (actually my internet provider's license forbids hosting a server) Does one exist for gitit? Also Gitit is an unfortunate name since Git It

Re: [Haskell-cafe] (no subject)

2009-08-22 Thread staafmeister
Thank you for the reply. Thomas ten Cate wrote: Although you most certainly can use a State monad, in most problems this isn't necessary. Most algorithms that you need to solve programming contest problems can be written in a purely functional style, so you can limit monadic code to just

Re: [Haskell-cafe] (no subject)

2009-08-22 Thread Sebastian Sylvan
On Sat, Aug 22, 2009 at 3:20 PM, staafmeister g.c.stave...@uu.nl wrote: Thank you for the reply. Thomas ten Cate wrote: Although you most certainly can use a State monad, in most problems this isn't necessary. Most algorithms that you need to solve programming contest problems can

Re: [Haskell-cafe] Help starting a Haskell blog

2009-08-22 Thread Jeremy Shaw
Hello, What I do is I write my blog posts using a literate Haskell + html. This allows me to actually run all the code and make sure it works. I can then use hscolour to transform the literal Haskell into html (with syntax highlighting). As a reader, I think you imagine that I have two distinct

Re: [Haskell-cafe] Help starting a Haskell blog

2009-08-22 Thread Dan Piponi
On Sat, Aug 22, 2009 at 3:35 AM, Peter Verswyvelenbugf...@gmail.com wrote: Could you share your experiences with me about starting a blog? BTW: I'm on Windows. I've found it hard work to post a mixture of English, Mathematics and Haskell. Neither of the most popular blogging web sites are very

[Haskell-cafe] How to calculate de number of digits of an integer? (was: Is logBase right?)

2009-08-22 Thread Roberto López
Ok. I wonder if someone could help me with this problem... I want to calculate the number of digits of a positive integer. I was thinking of ... numDigits n = truncate (logBase 10 n) + 1 But (logBase 10 1000) = 2.9996 so numDigits 1000 = 2. Maybe adding a small amount

Re: [Haskell-cafe] How to calculate de number of digits of an integer? (was: Is logBase right?)

2009-08-22 Thread Eugene Kirpichov
Use 'round' instead of 'truncate'. Prelude let numDigits = (+1) . round . logBase 10 . fromIntegral Prelude map (numDigits . (10^)) [0..9] [1,2,3,4,5,6,7,8,9,10] 2009/8/22 Roberto López plasterm...@hotmail.com: Ok. I wonder if someone could help me with this problem... I want to calculate the

Re: [Haskell-cafe] How to calculate de number of digits of an integer? (was: Is logBase right?)

2009-08-22 Thread Eugene Kirpichov
Or better numDigits = length . show It's probably even faster. 2009/8/22 Eugene Kirpichov ekirpic...@gmail.com: Use 'round' instead of 'truncate'. Prelude let numDigits = (+1) . round . logBase 10 . fromIntegral Prelude map (numDigits . (10^)) [0..9] [1,2,3,4,5,6,7,8,9,10] 2009/8/22

Re: [Haskell-cafe] How to calculate de number of digits of an integer? (was: Is logBase right?)

2009-08-22 Thread Derek Elkins
2009/8/22 Eugene Kirpichov ekirpic...@gmail.com: Use 'round' instead of 'truncate'. Prelude let numDigits = (+1) . round . logBase 10 . fromIntegral Prelude map (numDigits . (10^)) [0..9] [1,2,3,4,5,6,7,8,9,10] round won't work because 999 is close to 1000. You simply need to use logBase

Re: [Haskell-cafe] How to calculate de number of digits of an integer? (was: Is logBase right?)

2009-08-22 Thread Derek Elkins
On Sat, Aug 22, 2009 at 12:31 PM, Derek Elkinsderek.a.elk...@gmail.com wrote: 2009/8/22 Eugene Kirpichov ekirpic...@gmail.com: Use 'round' instead of 'truncate'. Prelude let numDigits = (+1) . round . logBase 10 . fromIntegral Prelude map (numDigits . (10^)) [0..9] [1,2,3,4,5,6,7,8,9,10]

Re: [Haskell-cafe] How to calculate de number of digits of an integer? (was: Is logBase right?)

2009-08-22 Thread Eugene Kirpichov
Ouch, my bad. length.show is better :) 2009/8/22 Derek Elkins derek.a.elk...@gmail.com: 2009/8/22 Eugene Kirpichov ekirpic...@gmail.com: Use 'round' instead of 'truncate'. Prelude let numDigits = (+1) . round . logBase 10 . fromIntegral Prelude map (numDigits . (10^)) [0..9]

Re: [Haskell-cafe] Help starting a Haskell blog

2009-08-22 Thread Gwern Branwen
On Sat, Aug 22, 2009 at 12:56 PM, Dan Piponidpip...@gmail.com wrote: On Sat, Aug 22, 2009 at 3:35 AM, Peter Verswyvelenbugf...@gmail.com wrote: Could you share your experiences with me about starting a blog? BTW: I'm on Windows. I've found it hard work to post a mixture of English,

Re: [Haskell-cafe] Help starting a Haskell blog

2009-08-22 Thread Gwern Branwen
On Sat, Aug 22, 2009 at 9:34 AM, Peter Verswyvelenbugf...@gmail.com wrote: Thanks. At first sight gitit requires that I setup my own server. That's how the Happstack model works. Although this has advantages and I did that in the past, I prefer to use a public server (actually my internet

Re: [Haskell-cafe] How to calculate de number of digits of an integer? (was: Is logBase right?)

2009-08-22 Thread Bulat Ziganshin
Hello Roberto, Saturday, August 22, 2009, 9:19:26 PM, you wrote: I want to calculate the number of digits of a positive integer. I was fastest way digits = iterate (`div` 10) takeWhile (0) length -- Best regards, Bulatmailto:bulat.zigans...@gmail.com

[Haskell-cafe] Re: Help starting a Haskell blog

2009-08-22 Thread Simon Michael
Nice tricks! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] How to calculate de number of digits of an integer? (was: Is logBase right?)

2009-08-22 Thread José Prous
It looks like length . show is faster Prelude Control.Arrow let numDigits n = length $ show n Prelude Control.Arrow let digits = iterate (`div` 10) takeWhile (0) length Prelude Control.Arrow let n=2^100 Prelude Control.Arrow :set +s Prelude Control.Arrow numDigits n 301030 (0.39 secs,

Re[2]: [Haskell-cafe] How to calculate de number of digits of an integer? (was: Is logBase right?)

2009-08-22 Thread Bulat Ziganshin
Hello José, Saturday, August 22, 2009, 10:36:33 PM, you wrote: ghci doesn't optimize It looks like length . show is faster -- Best regards, Bulatmailto:bulat.zigans...@gmail.com ___ Haskell-Cafe mailing list

[Haskell-cafe] Re: quick and dirty file parsing (was: no subject)

2009-08-22 Thread John Lato
From: staafmeister g.c.stave...@uu.nl Thank you for the reply. Thomas ten Cate wrote: Although you most certainly can use a State monad, in most problems this isn't necessary. Most algorithms that you need to solve programming contest problems can be written in a purely functional

[Haskell-cafe] ANN: haskell-src-exts-1.1.3

2009-08-22 Thread Niklas Broberg
Fellow Haskelleers, I'm pleased to announce the release of haskell-src-exts-1.1.3. * On hackage: http://hackage.haskell.org/package/haskell-src-exts * Via darcs: darcs get http://code.haskell.org/haskell-src-exts * Report bugs: http://trac.haskell.org/haskell-src-exts haskell-src-exts is a

Re: [Haskell-cafe] ANN: haskell-src-exts-1.1.3

2009-08-22 Thread Jeremy Shaw
Nice! Does this mean that in the near future trhsx won't strip out all the haddock comments? That would be great. - jeremy ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] Strange console IO behavior (at least on Windows)

2009-08-22 Thread Peter Verswyvelen
The following program http://hpaste.org/fastcgi/hpaste.fcgi/view?id=8445#a8445 should echo the ASCII code of each character the user types, on the fly, with no line buffering whatsoever. But it doesn't. At least not under Windows's cmd, and even less with msys. Under Windows, I have to press

Re: [Haskell-cafe] Strange console IO behavior (at least on Windows)

2009-08-22 Thread Jason Dagit
On Sat, Aug 22, 2009 at 2:14 PM, Peter Verswyvelenbugf...@gmail.com wrote: The following program http://hpaste.org/fastcgi/hpaste.fcgi/view?id=8445#a8445 should echo the ASCII code of each character the user types, on the fly, with no line buffering whatsoever. But it doesn't. At least not

Re: [Haskell-cafe] Strange console IO behavior (at least on Windows)

2009-08-22 Thread Peter Verswyvelen
Okay, I'll file a bug report. Maybe someone else on Windows could confirm this behavior? On Sat, Aug 22, 2009 at 11:36 PM, Jason Dagit da...@codersbase.com wrote: On Sat, Aug 22, 2009 at 2:14 PM, Peter Verswyvelenbugf...@gmail.com wrote: The following program

Re: [Haskell-cafe] Strange console IO behavior (at least on Windows)

2009-08-22 Thread Judah Jacobson
On Sat, Aug 22, 2009 at 2:37 PM, Peter Verswyvelenbugf...@gmail.com wrote: Okay, I'll file a bug report. Maybe someone else on Windows could confirm this behavior? On Sat, Aug 22, 2009 at 11:36 PM, Jason Dagit da...@codersbase.com wrote: On Sat, Aug 22, 2009 at 2:14 PM, Peter

Re: [Haskell-cafe] Strange console IO behavior (at least on Windows)

2009-08-22 Thread Peter Verswyvelen
Yep, that seems to be it. I should first do a search on trac before spamming here! But my first reaction when something basic as this goes wrong is blame myself and ask for help :-) On Sat, Aug 22, 2009 at 11:40 PM, Judah Jacobson judah.jacob...@gmail.comwrote: On Sat, Aug 22, 2009 at 2:37 PM,

[Haskell-cafe] oauth in haskell - reviewers?

2009-08-22 Thread Diego Souza
Hi all, I wrote a small library in haskell do deal with oauth authentication. It turns out it is my first library in haskell as well. As I'm beginner in haskell, I'm asking for a review of someone more experienced/proficient before even daring to create a cabal pkg and dist it to hackage. :-)

Re: [Haskell-cafe] Unifcation and matching in Abelian groups

2009-08-22 Thread Lennart Augustsson
Even if you are only slightly irritated by offset syntax, why are you using it? {;} works fine. On Sat, Aug 22, 2009 at 3:51 AM, John D. Ramsdellramsde...@gmail.com wrote: Let me put all my cards on the table.  You see, I really am only slightly irrigated by offset syntax.  In contrast, I am a

[Haskell-cafe] Takusen - is anyone currently using it on Win32 - ODBC?

2009-08-22 Thread Günther Schmidt
Hi all, is anyone currently using takusen with odbc on Win32? In particular with MS Access? I'm asking because I noticed that when database libraries are declared to work with ODBC no one seems to mean Win32 ODBC, but rather Unix ODBC. Günther

Re: [Haskell-cafe] oauth in haskell - reviewers?

2009-08-22 Thread Alexander Dunlap
On Sat, Aug 22, 2009 at 4:36 PM, Diego Souzadso...@bitforest.org wrote: Hi all, I wrote a small library in haskell do deal with oauth authentication. It turns out it is my first library in haskell as well. As I'm beginner in haskell, I'm asking for a review of someone more

[Haskell-cafe] Re: Strange console IO behavior (at least on Windows)

2009-08-22 Thread Tim Attwood
Yeah, it's broken in windows. Here's the workaround courtesy of Alistar Bayley. (ticket 2189) {-# LANGUAGE ForeignFunctionInterface #-} import Data.Char import Control.Monad (liftM, forever) import Foreign.C.Types getHiddenChar = liftM (chr.fromEnum) c_getch foreign import ccall unsafe

Re: [Haskell-cafe] (no subject)

2009-08-22 Thread Jake McArthur
staafmeister wrote: Yes I know but there are a lot of problems requiring O(1) array updates so then you are stuck with IO again Or use ST. Or use IntMap (which is O(log n), but n is going to max out on the integer size for your architecture, so it's really just O(32) or O(64), which is