Skip to content

Instantly share code, notes, and snippets.

@bpk-t
Last active March 5, 2017 08:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bpk-t/6feab8028b6a2fd322a0625192d85792 to your computer and use it in GitHub Desktop.
Save bpk-t/6feab8028b6a2fd322a0625192d85792 to your computer and use it in GitHub Desktop.

練習問題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