Sort a list of object identifiers: Difference between revisions
Sort a list of object identifiers (view source)
Revision as of 18:54, 25 February 2017
, 7 years ago→{{header|Haskell}}: (slightly simpler expression for the main function)
(→Task: promoted draft task to task.) |
(→{{header|Haskell}}: (slightly simpler expression for the main function)) |
||
Line 172:
<lang haskell>import Data.Text (pack, split, unpack)
import Data.List (sort, intercalate)
-- SORTING OBJECT IDENTIFIERS ------------------------------------------------
oidSort :: [String] -> [String]
oidSort =
(intercalate "." <$>) .
((show <$>) <$>) . sort . (((readInt
-- GENERIC FUNCTIONS ---------------------------------------------------------
splitString :: Char -> String -> [String]
splitString c s = unpack <$> split (c ==) (pack s)
readInt :: String -> Int
readInt xs = read xs :: Int
-- TEST ----------------------------------------------------------------------
main :: IO ()
Line 216:
oidSort =
(intercalate "." <$>) .
((show <$>) <$>) . sort . (((readInt
=={{header|J}}==
|