Created
March 25, 2011 14:36
-
-
Save msakai/886927 to your computer and use it in GitHub Desktop.
タプル化の簡単な例
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module TuplingExample where | |
import Prelude hiding (even, odd) | |
even :: Int -> Bool | |
even n = if n==0 then True else odd (n-1) | |
odd :: Int -> Bool | |
odd n = if n==0 then False else even (n-1) | |
-- タプル化したもの | |
even_and_odd :: Int -> (Bool, Bool) | |
even_and_odd n = | |
if n==0 | |
then (True, False) | |
else | |
case even_and_odd (n-1) of | |
(e, o) -> (o, e) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment