ghci> intersperse '.' "MONKEY" "M.O.N.K.E.Y" ghci> intercalate " " ["hey","there","guys"] "hey there guys" ghci> transpose [[1,2,3],[4,5,6],[7,8,9]] [[1,4,7],[2,5,8],[3,6,9]] ghci> concat [[3,4,5],[2,3,4],[2,1,1]] [3,4,5,2,3,4,2,1,1] ghci> concatMap (replicate 4) [1..3] [1,1,1,1,2,2,2,2,3,3,3,3] ghci> and $ map (>4) [5,6,7,8] True ghci> or $ map (==4) [2,3,4,5,6,1] True ghci> take 10 $ iterate (*2) 1 [1,2,4,8,16,32,64,128,256,512] ghci> splitAt 3 "heyman" ("hey","man") ghci> let (fw,rest) = span (/=' ') "This is a sentence" in "First word:" ++ fw ++ ",the rest:" ++ rest "First word: This,the rest: is a sentence" ghci> break (==4) [1,2,3,4,5,6,7] ([1,2,3],[4,5,6,7]) ghci> span (/=4) [1,2,3,4,5,6,7] ([1,2,3],[4,5,6,7]) ghci> sort [8,5,3,2,1,6,4,2] [1,2,2,3,4,5,6,8] ghci> group [1,1,1,1,2,2,2,2,3,3,2,2,2,5,6,7] [[1,1,1,1],[2,2,2,2],[3,3],[2,2,2],[5],[6],[7]] ghci> inits "w00t" ["","w","w0","w00","w00t"] ghci> tails "w00t" ["w00t","00t","0t","t",""] partition elem notElem elemIndex elemIndices find findIndex findIndices lines unlines words unwords nub delete \ ghci> [1..10] \ [2,5,9] [1,3,4,6,7,8,10] union intersection insert ghci> insert 4 [1,2,3,5,6,7] [1,2,3,4,5,6,7] ghci> let values = [-4.3,-2.4,-1.2,0.4,2.3,5.9,10.5,29.1,5.3,-2.4,-14.5,2.9,2.3] ghci> groupBy (x y -> (x > 0) == (y > 0)) values [[-4.3,-2.4,-1.2],[0.4,2.3,5.9,10.5,29.1,5.3],[-2.4,-14.5],[2.9,2.3]] on :: (b -> b -> c) -> (a -> b) -> a -> a -> c f `on` g = x y -> f (g x) (g y) ghci> groupBy ((==) `on` (> 0)) values [[-4.3,-2.4,-1.2],[0.4,2.3,5.9,10.5,29.1,5.3],[-2.4,-14.5],[2.9,2.3]]
|
近期评论