: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 ?
---
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-
>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
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!
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
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
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
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
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
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.
___
%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
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
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
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
14 matches
Mail list logo