Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?

練習問題A

Prelude> :{
Prelude| double :: Integer -> Integer
Prelude| double x = x * 2
Prelude| :}
Prelude> map double [1, 4, 4, 3]
[2,8,8,6]
Prelude> map (double . double) [1, 4, 4, 3]
[4,16,16,12]
Prelude> map double []
[]

練習問題B

(sin theta) ^ 2

練習問題C

Prelude> :t 'H'
'H' :: Char
Prelude> :t "H"
"H" :: [Char]
Prelude> :t 2001
2001 :: Num t => t
Prelude> :t "2001"
"2001" :: [Char]
Prelude> [1, 2, 3] ++ [3, 2, 1]
[1,2,3,3,2,1]
Prelude> "Hello" ++ " World"
"Hello World"
Prelude> [1, 2, 3] ++ []
[1,2,3]
Prelude> "Hello" ++ " " ++ "World"
"Hello World"

練習問題D

Prelude> :m Data.Char
Prelude Data.Char> words "test test test"
["test","test","test"]
Prelude Data.Char> (map (map toLower) . words) "ABC DEF"
["abc","def"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment