λ> [1,2,3] [1,2,3] λ> :t (^) (^) :: (Integral b, Num a) => a -> b -> a λ> :t (**) (**) :: Floating a => a -> a -> a λ> :t (^^) (^^) :: (Fractional a, Integral b) => a -> b -> a λ> :t 1 1 :: Num a => a λ> :t 1::Int 1::Int :: Int λ> :t 1.3 1.3 :: Fractional a => a λ> pythagoreanTriples 1 8 [(3,4,5),(4,3,5)] λ> pythagoreanTriples 1 8 [(3,4,5)] λ> pythagoreanTriples 1 15 [(3,4,5),(5,12,13),(6,8,10),(9,12,15)] λ> [ (x,y) | x <- [1..5], y <- [1..5] ] [(1,1),(1,2),(1,3),(1,4),(1,5),(2,1),(2,2),(2,3),(2,4),(2,5),(3,1),(3,2),(3,3),(3,4),(3,5),(4,1),(4,2),(4,3),(4,4),(4,5),(5,1),(5,2),(5,3),(5,4),(5,5)] λ> init [1..10] [1,2,3,4,5,6,7,8,9] λ> last [1..10] 10 λ> init [] *** Exception: /home/trifon/sync/Courses/2016_17/FPI_2016_17/sandbox/lists.hs:(52,1)-(53,23): Non-exhaustive patterns in function init λ> init [] *** Exception: Празен списък λ> take 3 [1..5] [1,2,3] λ> drop 3 [1..5] [4,5] λ> let matrix = [[1..5],[6..10],[11..15]] in [ drop 1 row | row <- matrix] [[2,3,4,5],[7,8,9,10],[12,13,14,15]] λ> let matrix = [[1..5],[6..10],[11..15]] in [ take 1 row | row <- matrix] [[1],[6],[11]] λ> let matrix = [[1..5],[6..10],[11..15]] in [ take 2 row | row <- matrix] [[1,2],[6,7],[11,12]] λ> let matrix = [[1..5],[6..10],[11..15]] in [ take 2 row ++ drop 3 row | row <- matrix] [[1,2,4,5],[6,7,9,10],[11,12,14,15]] λ> maximum [1..100] 100 λ> minimum [1..100] 1 λ> sum [1..10] 55 λ> const 2 const 2 :: Num a => b -> a λ> (const 2) 10 2 λ> (const 2) 1011 2 λ> (const 2) 10111343 2 λ> [ filter f x | x <- [[-2,1,0],[1,4,-1],[0,0,1]], f <- [(<0),(==0),(>0)]] [[-2],[0],[1],[-1],[],[1,4],[],[0,0],[1]] λ> [ (x,y) | x <- [1..5], y <- [1..5] ] [(1,1),(1,2),(1,3),(1,4),(1,5),(2,1),(2,2),(2,3),(2,4),(2,5),(3,1),(3,2),(3,3),(3,4),(3,5),(4,1),(4,2),(4,3),(4,4),(4,5),(5,1),(5,2),(5,3),(5,4),(5,5)] λ> [ (x,y) | x <- [1..3], y <- [1..5] ] [(1,1),(1,2),(1,3),(1,4),(1,5),(2,1),(2,2),(2,3),(2,4),(2,5),(3,1),(3,2),(3,3),(3,4),(3,5)] λ> map (\x -> map (\y -> (x,y)) [1..5]) [1..3] [[(1,1),(1,2),(1,3),(1,4),(1,5)],[(2,1),(2,2),(2,3),(2,4),(2,5)],[(3,1),(3,2),(3,3),(3,4),(3,5)]] λ> concat (map (\x -> map (\y -> (x,y)) [1..5]) [1..3]) [(1,1),(1,2),(1,3),(1,4),(1,5),(2,1),(2,2),(2,3),(2,4),(2,5),(3,1),(3,2),(3,3),(3,4),(3,5)] λ> map (^2) [1..10] [1,4,9,16,25,36,49,64,81,100] λ> filter even [1..10] [2,4,6,8,10] λ> filter even [1..10] [2,4,6,8,10] λ> flip (-) 5 3 -2 λ> (-) 5 3 2 λ> flip (-) 5 3 -2 λ> foldl (flip (:)) [] [1..10] [10,9,8,7,6,5,4,3,2,1] λ> last [1..10] 10 λ> last [1..10] 10 λ> scanr (+) 0 [1..5] [15,14,12,9,5,0] λ> scanr (+) 0 [1..5] [15,14,12,9,5,0] λ> foldl (+) 0 [1..5] 15 λ> scanl (+) 0 [1..5] [0,1,3,6,10,15] λ> zip [1..5] [2..10] [(1,2),(2,3),(3,4),(4,5),(5,6)] λ> unzip (zip [1..5] [2..10]) ([1,2,3,4,5],[2,3,4,5,6]) λ> zipWith (+) [1..3] [4..6] [5,7,9] λ> zip [1..5] [4..10] [(1,4),(2,5),(3,6),(4,7),(5,8)] λ> zip [1..5] [2..5] [(1,2),(2,3),(3,4),(4,5)] λ>