[Haskell-cafe] help with FFI

2009-09-17 Thread José Prous
Hello Lets say I have a library in C with a header like this: #include /*really big structure*/ typedef struct { int *a; int *b; /*lots of stuff ... */ int *z; } foo; /*this function allocate memory and fill the structure, reading from a file*/ int create_foo(foo *f,FILE *file,int x,int y); /

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

Re: [Haskell-cafe] Need some help with an infinite list

2009-06-16 Thread José Prous
this appears to work: alphabet=map (\x->x:[]) ['a'..'z'] series=alphabet++[x++y|x<-series,y<-alphabet] On Tue, Jun 16, 2009 at 8:28 PM, GüŸnther Schmidt wrote: > Hi guys, > > I'd like to generate an infinite list, like > > ["a", "b", "c" .. "z", "aa", "ab", "ac" .. "az", "ba", "bb", "bc" .. "bz"

Re: [Haskell-cafe] Random Number

2009-06-07 Thread José Prous
look in System.Random randomRIO :: (Random a) => (a, a) -> IO a you can do randomNumber<-randomRIO (1,30) On Sun, Jun 7, 2009 at 3:33 PM, ptrash wrote: > > Hi, > > is the are way (or a build in method) in haskell to get a random number > from > a number bottom to a number top? > > Something li