Skip to content

Instantly share code, notes, and snippets.

@tokiwoousaka
Created June 5, 2015 05:20
Show Gist options
  • Save tokiwoousaka/edf34842fbc84ab34511 to your computer and use it in GitHub Desktop.
Save tokiwoousaka/edf34842fbc84ab34511 to your computer and use it in GitHub Desktop.
module Main where
true :: a -> b -> a
true x _ = x
false :: a -> b -> b
false _ x = x
iF :: (a -> a -> a) -> a -> a -> a
iF b x y = b x y
-- 高階関数をいい感じに駆使すると
-- 関数だけで条件分岐が出来る不思議
main :: IO ()
main = do
putStrLn (iF true "ほげ" "ぴよ") -- ほげ
putStrLn (iF false "ほげ" "ぴよ") -- ぴよ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment