2008-01-15``Programming in Haskell'' (45) 4.8 Exercise 5.
別バージョンの && を conditional expression で書け
演算子の定義が良く分からないので、関数で
conjunction b c = if b then c else False
で、
*Main> conjunction True True True *Main> conjunction True False False *Main> conjunction False True False *Main> conjunction False False False
トラックバック - http://haskell.g.hatena.ne.jp/noritsugu/20080115
(&&) を hidding 指定するか,呼び出しの際に自作モジュール名で修飾します.
方法1:
import Prelude hiding ((&&))
(&&) :: Bool -> Bool -> Bool
p && q = if p then q else False
方法2:
module Foo where
(&&) :: Bool -> Bool -> Bool
p && q = if p then q else False
{-
*Foo> True Foo.&& False
False
-}