module Data.List.Extra where
import Data.Bool.Extra
import Data.List
import Data.Maybe
list :: b -> ([a] -> b) -> [a] -> b
list nil cons = cond (const nil) cons null
unionOf :: (Eq a) => [[a]] -> [a]
unionOf = foldr union []
for :: [a] -> (a -> b) -> [b]
for = flip map
lastToMaybe :: [a] -> Maybe a
lastToMaybe [x] = Just x
lastToMaybe (_:xs) = lastToMaybe xs
lastToMaybe [] = Nothing
firstOr :: a -> [a] -> a
firstOr n = fromMaybe n . listToMaybe
maxList :: (Num t, Ord t) => [t] -> t
maxList [] = 0
maxList xs = maximum xs