Re: [Haskell-cafe] Can i split a String by its element ?

2011-02-22 Thread z_axis
:hoogle splitOn No results found :m + Data.Text splitOn "," "2,15,33,0,8,1,16,18" :1:8: Couldn't match expected type `Text' against inferred type `[Char]` ... :i splitOn splitOn :: Text -> Text -> [Text] -- Defined in Data.Text It seems this "splitOn" is not one used by you ? ---

[Haskell-cafe] Can i split a String by its element ?

2011-02-21 Thread z_axis
I want to split "2,15,33,0,8,1,16,18" to ([2,15,33],[8,1,16,18]). the "0" will by discarded. However, it seems that there isnot any standard function to do it. Sincerely! - e^(π.i) + 1 = 0 -- View this message in context: http://haskell.1045720.n5.nabble.com/Can-i-split-a-String-by-its-

[Haskell-cafe] `cabal install darcs` fail !

2011-02-17 Thread z_axis
>cabal update >cabal install darcs .. Installing library in /home/sw2wolf/.cabal/lib/hashed-storage-0.5.5/ghc-6.10.4 Registering hashed-storage-0.5.5... Reading package info from "dist/installed-pkg-config" ... done. Writing new package config file... done. cabal: Error: some packages failed t

[Haskell-cafe] The "type & data" constructor confused me !

2011-01-12 Thread z_axis
data Layout a = forall l. (LayoutClass l a, Read (l a)) => Layout (l a) readsLayout :: Layout a -> String -> [(Layout a, String)] readsLayout (Layout l) s = [(Layout (asTypeOf x l), rs) | (x, rs) <- reads s] Why is the first parameter of readsLayout "(Layout l)" not "Layout (l a)" ? Sincerely!

Re: [Haskell-cafe] How to write such a code elegantly ?

2011-01-09 Thread z_axis
rollDice n = do tmp <- doesFileExist "/dev/urandom" myGen <- if tmp then betterStdGen else (mkStdGen . fromInteger) <$> picoSec return $ (take 1 $ randomRs (1,n) myGen) !! 0 works but not so elegant? - e^(π.i) + 1 = 0 -- View this message in context: htt

Re: [Haskell-cafe] How to write such a code elegantly ?

2011-01-09 Thread z_axis
thanks for all of your replies. I will test your code later. Another newbie question is why has the following code indentation problem ? rollDice n = do let myGen = if doesFileExist "/dev/urandom" then betterStdGen else (mkStdGen . fromInteger) <$> picoSec

[Haskell-cafe] How to write such a code elegantly ?

2011-01-09 Thread z_axis
betterStdGen :: IO StdGen betterStdGen = alloca $ \p -> do h <- openBinaryFile "/dev/urandom" ReadMode hGetBuf h p $ sizeOf (undefined :: Int) hClose h mkStdGen <$> peek p picoSec :: IO Integer picoSec = do t <- ctPicosec `liftM` (getClockTime >>= toCalendarTime) return t The

[Haskell-cafe] What's the best seed for random API ?

2011-01-05 Thread z_axis
picoSec :: IO Integer picoSec = do t <- ctPicosec `liftM` (getClockTime >>= toCalendarTime) return t rollDice :: Int -> IO Int rollDice n = do ps <- picoSec return $ (take 1 $ randomRs (1,n) $ mkStdGen $ fromInteger ps) !! 0 The above code uses `ctPicosec` as seed. Is it better

Re: [Haskell-cafe] Beginners help

2010-12-15 Thread z_axis
According to map's definition, we know the 'fs' should be a list of function. so 'p' need a [a->b] as its parameter.And the result of 'p' should be a list of function which accepts [a] and return [b]. So the type of 'p' is [a->b] -> [[a] -> [b]] hope i make it clear. - e^(π.i) + 1 = 0

Re: [Haskell-cafe] cannot install regex-posix using cabal ?

2010-12-15 Thread z_axis
canot it be fixed ? - e^(π.i) + 1 = 0 -- View this message in context: http://haskell.1045720.n5.nabble.com/cannot-install-regex-posix-using-cabal-tp3301201p3307465.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___

[Haskell-cafe] cannot install regex-posix using cabal ?

2010-12-10 Thread z_axis
%ghc-pkg list|grep -i regex regex-base-0.93.2 %cabal install regex-posix Resolving dependencies... Configuring regex-posix-0.94.4... Preprocessing library regex-posix-0.94.4... running dist/build/Text/Regex/Posix/Wrap_hsc_make failed command was: dist/build/Text/Regex/Posix/Wrap_hsc_make >di

[Haskell-cafe] How to use Data.ByteString ?

2009-05-18 Thread z_axis
Hi, friends the following function works well rollDice n = getStdRandom (randomR (1,n)) :: IO Int now i want to use /dev/random to produce better random number, but it doesnot work rollDice_t n = do hd <- openFile "/dev/random" ReadMode v <- B.hGet hd 1 return (v `mod` n) + 1 No in

[Haskell-cafe] How to understand the fmap here ?

2009-05-05 Thread z_axis
r f where fmap :: (a -> b) -> f a -> f b It seems it is different from the definition of fmap ? sincerely! 2009-05-05 z_axis ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] about logical computation

2008-09-29 Thread z_axis
hi, friends I am a Haskell newbie however i like it very much. After starting learn haskell, i donot find the corresponding "&", "|" , "~", "<<", ">>" logical computation of C language. Sincere