Skip to content

Instantly share code, notes, and snippets.

@msakai
Created March 25, 2011 14:36
Show Gist options
  • Save msakai/886927 to your computer and use it in GitHub Desktop.
Save msakai/886927 to your computer and use it in GitHub Desktop.
タプル化の簡単な例
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