← all modules

Sky.Core.List

Sky.Core.List
  Sky.Core.List — list combinators.

Values
  any : (a -> Bool) -> List a -> Bool
      `any pred list` — True iff `pred` holds for at least one element.
  append : List a -> List a -> List a
      `append xs ys` — concatenate two lists.
  concat : List (List a) -> List a
      `concat lists` — flatten a list of lists.
  concatMap : (a -> List b) -> List a -> List b
      `concatMap fn list` — map each element to a list and flatten
  cons : a -> List a -> List a
      `cons x list` — prepend `x` (the `::` operator as a named function).
  drop : Int -> List a -> List a
      `drop n list` — `list` without its first `n` elements. `drop 0` and
  filter : (a -> Bool) -> List a -> List a
      `filter pred list` — keep only elements satisfying `pred`.
  filterMap : (a -> Maybe b) -> List a -> List b
      `filterMap fn list` — map each element and keep only the `Just` results
  foldl : (a -> b -> b) -> b -> List a -> b
      `foldl fn acc list` — left fold: `fn aN (… (fn a1 (fn a0 acc)))`.
  foldr : (a -> b -> b) -> b -> List a -> b
      `foldr fn acc list` — right fold: `fn a0 (fn a1 (… (fn aN acc)))`.
  indexedMap : (Int -> a -> b) -> List a -> List b
      `indexedMap fn list` — apply `fn` to each zero-based `(index, element)`
  isEmpty : List a -> Bool
      `isEmpty list` — True iff the list has no elements.
  length : List a -> Int
      `length list` — number of elements (O(1) on the slice representation).
  map : (a -> b) -> List a -> List b
      `map fn list` — apply `fn` to each element.
  map2 : (a -> b -> c) -> List a -> List b -> List c
      `map2 f xs ys` — `f` applied to the elements of `xs` and `ys` pair by
  map3 : (a -> b -> c -> d) -> List a -> List b -> List c -> List d
      `map3 f xs ys zs` — like `map2` over three lists, stopping at the end
  range : Int -> Int -> List Int
      `range lo hi` — `[lo, lo + 1, …, hi]` (inclusive). `lo > hi` gives `[]`.
  repeat : Int -> a -> List a
      `repeat n x` — a list of `n` copies of `x`, as in Elm. An `n` of 0 or less
  reverse : List a -> List a
      `reverse list` — the list in reverse order.
  sort : List comparable -> List comparable
      `sort list` — ascending, stable sort. The elements must be comparable:
  sortBy : (a -> comparable) -> List a -> List a
      `sortBy keyFn list` — stable sort by the key `keyFn elem`, which must be
  sortWith : (a -> a -> Int) -> List a -> List a
      `sortWith cmp list` — stable sort by a custom comparator. `cmp a b`
  take : Int -> List a -> List a
      `take n list` — first `n` elements (or fewer when `list` is shorter).
  unique : List comparable -> List comparable
      `unique xs` — `xs` with every value kept only at its FIRST occurrence,
  zip : List a -> List b -> List ( a, b )
      `zip xs ys` — pair-wise zip, truncated to the shorter list's length.
  all
      `all pred xs` — `True` when every element passes `pred` (`True` for `[]`).
  find
      `find pred xs` — the first element that passes `pred`, or `Nothing`.
  head
      `head xs` — the first element, or `Nothing` for `[]`.
  tail
      `tail xs` — every element but the first, or `Nothing` for `[]`.
  member
      `member x xs` — `True` when `x` is an element of `xs`.