ListUtil.hs
{-# LANGUAGE TransformListComp #-} import GHC.Exts sortList :: [String] -> [String] sortList list = [x | x <- list, then sortWith by (length x)]
Prelude> :load ListUtil.hs [1 of 1] Compiling Main ( ListUtil.hs, interpreted ) Ok, modules loaded: Main. *Main> *Main> sortList ["Hari", "Krishna", "PTR", "Nayan"] ["PTR","Hari","Nayan","Krishna"]
No comments:
Post a Comment