Numbers3+2 3-2 3*2 3/2 3^2 3**2.5div3 2 mod3 2 ... max3 4 min3 4 abs(-3) odd3 even3 gcd4 6 lcm4 6 floor3.6 round3.6 ceiling3.6 sum[1..5] product[1..5] maximum[1,3,2] minimum[1,3,2] pi sqrt2 sin0.4 cos0.4 ... Booleans3>2 3>=2 3<2 3<=2 3==2 3/=2True&&False True||False notTrue and[False, False, True] or[False, False, True] Constructing Lists'h':"ello" "he"++"llo" replicate3 'a'concat["he", "ll", "o"] ... intersperse',' "abc" intercalate"--" ["one", "two"] Querying Listsnull"abc" length"abc"eleme "hello" findodd [2,4,5,6] ... isPrefixOf"he" "hello" ... FindIndexodd [2,3,5] FindIndicesodd [2,3,5] |
Extracting from Lists"hello"!!4head"abc" tail"abc" init"abc" last"abc" take2 "hello" drop2 "hello" takeWhileodd [1,3,2] dropWhileodd [1,3,2] stripPrefix"he" "hello" Splitting ListssplitAt2 "hello" spanodd [1,3,4] breakeven [1,3,4]partitionodd [1,2,3,4] Infinite listsiterate(+1) 0 repeat'a' cycle"hello"Lists as setsnub"mississippi"delete'e' "hello" "ab"\\"ac" union"ab" "ac" ... Sortingsort[3,4,2] ... insert3 [1,2,4] ... compare3 4Misc Listszip[1..] "hello" zipWith(+) [1,2,3] [4,5,6] ...unzip[(4,'a'),(5,'z')] ... reverse"hi" transpose["abc", "123"] subsequences"abc" permutations"abc" group"hello" inits"abc" tails"abc" |
Stringslines"one\ntwo\n" unlines["one", "two"]words"one two" unwords["one", "two"] show3 read"3" CharacterstoUpper'a' toLower'A'digitToInt'5' intToDigit5 ord'A' chr65 isNumber'4' isLetter'a' ... Higher ordermapsqrt [1..5] filterodd [1..5]allodd [2,3,4] anyodd [2,3,4] sqrt.sqrt sqrt$4 fliptake foldr(+) 0 [1..5] foldl'(+) 0 [1..5] ... scanr(+) 0 [1..5] scanl'(+) 0 [1..5] ... I/Omain interact$ map toUpperputChar'a' putStr"hi" putStrLn"hi" print4 getchar getLine getContents readFile"a.txt" writeFile"a.txt" "hello" appendFile"a.txt" "hello" Miscfst(3,"hi") snd(3,"hi") id3 const3 "hi" |