never executed always true always false
    1 module Data.List.Extra where
    2 
    3 import Elm.Utils ((|>))
    4 import qualified Data.List as List
    5 
    6 
    7 pairs :: [a] -> [(a,a)]
    8 pairs input =
    9     let
   10         step next ( prev, acc ) =
   11             case prev of
   12                 Nothing ->
   13                     ( Just next, acc )
   14                 Just prev' ->
   15                     ( Just next, ( next, prev' ) : acc )
   16     in
   17         List.foldr step (Nothing, []) input
   18             |> snd
   19 
   20 
   21 intersperseMap :: (a -> a -> [b]) -> (a -> b) -> [a] -> [b]
   22 intersperseMap spacer fn list =
   23     case list of
   24         [] -> []
   25         (first:_) ->
   26             fn first
   27               : (pairs list
   28                   |> concatMap (\(a,b) -> spacer a b ++ [fn b]))
   29 
   30 
   31 shift :: a -> [(b,a)] -> ([(a,b)], a)
   32 shift a list =
   33     let
   34         init = (a, [])
   35         step (holdA, acc) (nextB, nextA) =
   36             (nextA, (holdA, nextB) : acc)
   37         done (holdA, acc) =
   38             (List.reverse acc, holdA)
   39     in
   40         List.foldl step init list
   41             |> done