Idiomatically determine all the lowercase and uppercase letters: Difference between revisions

m
→‎{{header|Haskell}}: Reduced a little in terms of Data.Bifunctor
No edit summary
m (→‎{{header|Haskell}}: Reduced a little in terms of Data.Bifunctor)
Line 325:
 
And if we want to generalise a little beyond a narrowly Anglo-Saxon notion of the alphabet:
<lang Haskell>import Data.ListChar (partitionchr, isPrint, isUpper, isLower)
import Data.CharBifunctor (chr, isPrint, isUpper, isLowersecond)
import Data.List (partition)
 
uppersAndLowers :: (String, String)
uppersAndLowers =
second
let glyphs = filter isPrint (chr <$> [1 .. 0x10ffff])
(us,fst rs) =. partition isUpper glyphsisLower)
let glyphs =(partition isUpper $ filter isPrint (chr <$> [1 .. 0x10ffff]))
(ls, _) = partition isLower rs
in (us, ls)
 
chunksOf :: Int -> [a] -> [[a]]
Line 343:
main :: IO ()
main = do
mapM_ putStrLn ($ "Upper:" : chunksOf 70 (fst uppersAndLowers))
putStrLn ""[]
mapM_ putStrLn ($ "Lower:" : chunksOf 70 (snd uppersAndLowers))</lang>
{{Out}}
<pre>Upper:
9,655

edits