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
add 1 = 1 | |
add n = n + add (n - 1) |
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
putStrLn $ unlines $ replicate 5 $ "Hello,World" | |
putStrLn $ unwords $ replicate 5 $ "Hello,World¥n" | |
{ -unlinesとunwordsの違いは改行がつくかつかないかです。 | |
unlinesはつきますが、unwordsはつきません。— } |
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
main :: IO () | |
main = putStrLn "Hello,World" |
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
{ - if分はスマートに書けねえ・・。 | |
そんなスマートじゃなくてすいません。 - } | |
num x = do | |
if x `mod` 3 == 0 | |
then "fizz" | |
else if x `mod` 5 == 0 | |
then "buzz" | |
else if x `mod` 15 == 0 | |
then "fizzbuzz" | |
else show x |
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
sum x = (read :: String -> Int) x | |
getInt = do m <- getLine ; return (sum m) |
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
sumTo x = (read :: String -> Int) x | |
getInt = do m <- getLine ; return (sumTo m) | |
family list = (sum list) `div` (length list) | |
main = do | |
putStrLn "mother " ; m <- getInt | |
putStrLn "father " ; f <- getInt | |
putStrLn "brother " ; b <- getInt | |
putStrLn "me " ; me <- getInt | |
putStr ("平均年齢は" ++ (show (family [m, f, b, me])) ++ "歳。") |
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
avtokyo t = do | |
putStr "当日8000円(a)/前売り5000円(b)/合計(c)" | |
s <- getChar | |
putStr "\n" | |
case s of | |
'a' -> avtokyo (t + 8000) | |
'b' -> avtokyo (t + 5000) | |
'c' -> return t | |
_ -> (do putStr "入力 "; avtokyo t) | |
main = do |
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
sumTo x = (read :: String -> Int) x | |
getInt = do m <- getLine ; return (sumTo m) | |
act n = do | |
if (n`mod` 3 == 0) && (n`mod`4 == 0) | |
then print n | |
else return () | |
cal i i2 keisan = do | |
keisan i | |
if i /= i2 | |
then cal (i+1) i2 keisan |
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
sumTo x = (read :: String -> Int) x | |
getInt = do m <- getLine ; return (sumTo m) | |
suido w = do | |
if w == 10 | |
then show(1150-4200) | |
else if w <= 20 | |
then show(4280-(1150+(w-10) * 125)) | |
else if w <= 30 | |
then show(4280-(1150+10*125+(w-20)*140)) | |
else show(4280-(1150+10*125+10*140+(w-30)*160)) |
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
sumTo x = (read :: String -> Int) x | |
getInt = do m <- getLine;return (sumTo m) | |
heikin list = (sum list) `div` (length list) | |
-- 条件の関数 | |
joken list = do | |
if (!!) list 0 == 100 || (!!) list 1 == 100 || (!!) list 2 == 100 | |
then "A" | |
else if ((!!) list 0 + (!!) list 1) `div` 2 >= 90 | |
then "A" | |
else if heikin list >= 80 |
OlderNewer