Jump to content

Sort a list of object identifiers: Difference between revisions

m
m (→‎{{header|REXX}}: changed/added comments and whitespace, added whitespace to the ouput.)
Line 134:
=={{header|Haskell}}==
<lang Haskell>import Data.List ( sort , intercalate )
 
oid :: [String]
oid = ["1.3.6.1.4.1.11.2.17.19.3.4.0.10",
"1.3.6.1.4.1.11.2.17.5.2.0.79" ,
"1.3.6.1.4.1.11.2.17.19.3.4.0.4" ,
"1.3.6.1.4.1.11150.3.4.0.1" ,
"1.3.6.1.4.1.11.2.17.19.3.4.0.1" ,
"1.3.6.1.4.1.11150.3.4.0"]
 
splitString :: Eq a => (a) -> [a] -> [[a]]
Line 152 ⟶ 144:
convertIntListToString = intercalate "." . map show
 
orderOID :: [String] -> [String]
orderOID = map convertIntListToString . sort . map ( map read . splitString '.' )
 
map ( map read . splitString '.' ) $ oid
oid :: [String]
oid = ["1.3.6.1.4.1.11.2.17.19.3.4.0.10" ,
"1.3.6.1.4.1.11.2.17.5.2.0.79" ,
"1.3.6.1.4.1.11.2.17.19.3.4.0.4" ,
"1.3.6.1.4.1.11150.3.4.0.1" ,
"1.3.6.1.4.1.11.2.17.19.3.4.0.1" ,
"1.3.6.1.4.1.11150.3.4.0"]
 
main :: IO ( )
main = do
mapM_ putStrLn $ orderOID oid</lang>
 
{{out}}
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.