Шаг 109.
Основы языка Haskell.
Функционалы (функции высшего порядка). Утилиты для работы со списками

    На этом шаге мы перечислим некоторые операции над списками.

    В библиотеке List определены некоторые редко используемые операции над списками.

   module List (
      elemIndex, elemIndices,
      find, findIndex, findIndices,
      nub, nubBy, delete, deleteBy, (\\), deleteFirstsBy,
      union, unionBy, intersect, intersectBy,
      intersperse, transpose, partition, group, groupBy,
      inits, tails, isPrefixOf, isSuffixOf,
      mapAccumL, mapAccumR,
      sort, sortBy, insert, insertBy, maximumBy, minimumBy,
      genericLength, genericTake, genericDrop,
      genericSplitAt, genericIndex, genericReplicate,
      zip4, zip5, zip6, zip7,
      zipWith4, zipWith5, zipWith6, zipWith7,
      unzip4, unzip5, unzip6, unzip7, unfoldr,
      -- ... и то, что экспортирует Prelude
      -- []((:), []), -- Это встроенный синтаксис
      map, (++), concat, filter,
      head, last, tail, init, null, length, (!!),
      foldl, foldl1, scanl, scanl1, foldr, foldr1, scanr, scanr1,
      iterate, repeat, replicate, cycle,
      take, drop, splitAt, takeWhile, dropWhile, span, break,
      lines, words, unlines, unwords, reverse, and, or,
      any, all, elem, notElem, lookup,
      sum, product, maximum, minimum, concatMap,
      zip, zip3, zipWith, zipWith3, unzip, unzip3
      ) where
   infix 5 \\

   elemIndex :: Eq a => a -> [a] -> Maybe Int
   elemIndices :: Eq a => a -> [a] -> [Int]
   find :: (a -> Bool) -> [a] -> Maybe a
   findIndex :: (a -> Bool) -> [a] -> Maybe Int
   findIndices :: (a -> Bool) -> [a] -> [Int]
   nub :: Eq a => [a] -> [a]
   nubBy :: (a -> a -> Bool) -> [a] -> [a]
   delete :: Eq a => a -> [a] -> [a]
   deleteBy :: (a -> a -> Bool) -> a -> [a] -> [a]
   (\\) :: Eq a => [a] -> [a] -> [a]
   deleteFirstsBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]
   union :: Eq a => [a] -> [a] -> [a]
   unionBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]
   intersect :: Eq a => [a] -> [a] -> [a]
   intersectBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]
   intersperse :: a -> [a] -> [a]
   transpose :: [[a]] -> [[a]]
   partition :: (a -> Bool) -> [a] -> ([a],[a])
   group :: Eq a => [a] -> [[a]]
   groupBy :: (a -> a -> Bool) -> [a] -> [[a]]
   inits :: [a] -> [[a]]
   tails :: [a] -> [[a]]
   isPrefixOf :: Eq a => [a] -> [a] -> Bool
   isSuffixOf :: Eq a => [a] -> [a] -> Bool
   mapAccumL :: (a -> b -> (a, c)) -> a -> [b] -> (a, [c])
   mapAccumR :: (a -> b -> (a, c)) -> a -> [b] -> (a, [c])
   unfoldr :: (b -> Maybe (a,b)) -> b -> [a]
   sort :: Ord a => [a] -> [a]
   sortBy :: (a -> a -> Ordering) -> [a] -> [a]
   insert :: Ord a => a -> [a] -> [a]
   insertBy :: (a -> a -> Ordering) -> a -> [a] -> [a]
   maximumBy :: (a -> a -> Ordering) -> [a] -> a
   minimumBy :: (a -> a -> Ordering) -> [a] -> a
   genericLength :: Integral a => [b] -> a
   genericTake :: Integral a => a -> [b] -> [b]
   genericDrop :: Integral a => a -> [b] -> [b]
   genericSplitAt :: Integral a => a -> [b] -> ([b],[b])
   genericIndex :: Integral a => [b] -> a -> b
   genericReplicate :: Integral a => a -> b -> [b]
   zip4 :: [a] -> [b] -> [c] -> [d] -> [(a,b,c,d)]
   zip5 :: [a] -> [b] -> [c] -> [d] -> [e] -> [(a,b,c,d,e)]
   zip6 :: [a] -> [b] -> [c] -> [d] -> [e] -> [f]
         -> [(a,b,c,d,e,f)]
   zip7 :: [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g]
         -> [(a,b,c,d,e,f,g)]
   zipWith4 :: (a->b->c->d->e) -> [a]->[b]->[c]->[d]->[e]
   zipWith5 :: (a->b->c->d->e->f) ->
   [a]->[b]->[c]->[d]->[e]->[f]
   zipWith6 :: (a->b->c->d->e->f->g) ->
   [a]->[b]->[c]->[d]->[e]->[f]->[g]
   zipWith7 :: (a->b->c->d->e->f->g->h) ->
   [a]->[b]->[c]->[d]->[e]->[f]->[g]->[h]
   unzip4 :: [(a,b,c,d)] -> ([a],[b],[c],[d])
   unzip5 :: [(a,b,c,d,e)] -> ([a],[b],[c],[d],[e])
   unzip6 :: [(a,b,c,d,e,f)] -> ([a],[b],[c],[d],[e],[f])
   unzip7 :: [(a,b,c,d,e,f,g)] -> ([a],[b],[c],[d],[e],[f],[g])

    На следующем шаге мы приведем перечень задач для самостоятельного решения.




Предыдущий шаг Содержание Следующий шаг