|
|
|
|
|
by ostso
5491 days ago
|
|
"bar none" is a little excessive -- Haskell's syntax is probably even cleaner. Compare: 1. map (*2) [1..10]
2. sum [1..1000]
-- sum = foldl (+) 0
3. any (`isInfixOf` tweet) wordlist
4. fileText <- readFile "data.txt"
fileLines <- lines <$> readFile "data.txt"
5. mapM_ putStrLn . map (\i -> "Happy Birthday " ++ if i == 3 then "dear NAME" else "to You") $ [1..4]
6. (passed, failed) = partition (>60) [49,58,76,82,88,90]
7. -- I avoid XML so I don't know what library you'd use here.
8. minimum [14, 35, -7, 46, 98]
-- minimum = foldl1 min
|
|
And ditto for Io (http://www.iolanguage.com):
Some notes:i) For 1 & 2 remember to have `Range` loaded first. ii). OK I cheated on 6 because there is no partition currently in the Io core lib. Here is a "simple" way I did it for the example: