2014년 3월 27일 목요일

Convert "If Sentence" to Functional

foo x = case x of
   Just x     -> ...
   Nothing -> ...
is same to
foo (Just x)     = ...
foo (Nothing) = ...

case mbx of
   Just x
      | x > 10      -> ...
      | x < 0        -> ...
      | otherwise -> ...
   Nothing        -> ...
is same to
foo (Just x)
   | x > 10        = ...
   | x < 0          = ...
   | otherwise   = ...
foo (Nothing) = ...

댓글 없음:

댓글 쓰기