  Shortest list , lazily
-- 

module ShortestList where

import Data.List (findIndex)
import Data.Maybe (fromMaybe)

shortestList :: [[a]] -> [a]
shortestList [] = []
shortestList xs = let i ys = fromMaybe (i (map tail ys)) . findIndex null $ ys in xs !! i xs

  Shortest list , lazily

module ShortestList where

import Data.List (findIndex)
import Data.Maybe (fromMaybe)

shortestList :: [[a]] -> [a]
shortestList [] = []
shortestList xs = let i ys = fromMaybe (i (map tail ys)) . findIndex null $ ys in xs !! i xs
