    -- |
    -- Module:      Math.NumberTheory.Zeta.Utils
    -- Copyright:   (c) 2018 Alexandre Rodrigues Baldé
    -- Licence:     MIT
    -- Maintainer:  Alexandre Rodrigues Baldé <alexandrer_b@outlook.com>
    --
    -- Shared utilities used by functions from @Math.NumberTheory.Zeta@.

    module Math.NumberTheory.Zeta.Utils
      ( intertwine
      , skipEvens
      , skipOdds
      ) where

    -- | Joins two lists element-by-element together into one, starting with the
    -- first one provided as argument.
    --
    -- >>> take 10 (intertwine [0, 2 ..] [1, 3 ..])
    -- [0,1,2,3,4,5,6,7,8,9]
    intertwine :: [a] -> [a] -> [a]
    intertwine :: forall a. [a] -> [a] -> [a]
    intertwine [] [a]
    ys = [a]
    ys
    intertwine (a
    x : [a]
    xs) [a]
    ys = a
    x a -> [a] -> [a]
    forall a. a -> [a] -> [a]
    : [a] -> [a] -> [a]
    forall a. [a] -> [a] -> [a]
    intertwine [a]
    ys [a]
    xs

    -- | Skips every odd-indexed element from an infinite list.
    -- Do NOT use with finite lists.
    --
    -- >>> take 10 (skipOdds [0, 1 ..])
    -- [0,2,4,6,8,10,12,14,16,18]
    skipOdds :: [a] -> [a]
    skipOdds :: forall a. [a] -> [a]
    skipOdds (a
    x : a
    _ : [a]
    xs) = a
    x a -> [a] -> [a]
    forall a. a -> [a] -> [a]
    : [a] -> [a]
    forall a. [a] -> [a]
    skipOdds [a]
    xs
    skipOdds [a]
    xs = [a]
    xs

    -- | Skips every even-indexed element from an infinite list.
    -- Do NOT use with finite lists.
    --
    -- >>> take 10 (skipEvens [0, 1 ..])
    -- [1,3,5,7,9,11,13,15,17,19]
    skipEvens :: [a] -> [a]
    skipEvens :: forall a. [a] -> [a]
    skipEvens = [a] -> [a]
    forall a. [a] -> [a]
    skipOdds ([a] -> [a]) -> ([a] -> [a]) -> [a] -> [a]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [a] -> [a]
    forall a. HasCallStack => [a] -> [a]
    tail