Showing posts with label Haskell. Show all posts
Showing posts with label Haskell. Show all posts
2010-07-12
2010-07-02
2010-06-30
superdot
Prelude Control.Applicative> let superdot =
(((<*>).(((<*>).).(((.).).).(.)))<*>const const)
Prelude ...> :t superdot
superdot ::
(b -> b -> c) -> (b1 -> b) -> b1 -> b1 -> c
Prelude ...> superdot compare snd (0, 1) (0, 0)
GT
Hi, it is NISHIO Hirokazu. I just needed "dot" operator for 2-args function.
Prelude ...> let superdot = \f g x y -> f (g x) (g y)
Prelude ...> superdot compare snd (0, 1) (1, 0)
GT
Why such a function isn't in Prelude?
2010-06-22
2010-06-09
Haskell's random
Hi, it is NISHIO Hirokazu, Haskell newbie. Today I post a small code. It's not a bug. It's a feature of Haskell.
Yes, it is a feature. Haskell's random changes its behavior by what type inferred. See The Haskell 98 Library Report: Random Numbers.
$ ghci
GHCi, version 6.8.3
Prelude> import Random
Prelude Random> let g = mkStdGen 1
Prelude Random> (fst (random g)) + 0
-604496784
Prelude Random> (fst (random g)) / 1
0.35925462466181596
Prelude Random> (fst (random g)) * 1
-604496784
Prelude Random> (fst (random g)) * 1.0
0.35925462466181596
Yes, it is a feature. Haskell's random changes its behavior by what type inferred. See The Haskell 98 Library Report: Random Numbers.
Subscribe to:
Posts (Atom)