Idiomatically determine all the lowercase and uppercase letters: Difference between revisions
Content added Content deleted
Line 561: | Line 561: | ||
And if we want to generalise a little beyond a narrowly Anglo-Saxon notion of alphabets: |
And if we want to generalise a little beyond a narrowly Anglo-Saxon notion of alphabets: |
||
<lang Haskell>import Control.Monad (join) |
<lang Haskell>import Control.Monad (join) |
||
import Data.Bool (bool) |
|||
import Data.Bifunctor (bimap, second) |
import Data.Bifunctor (bimap, second) |
||
import Data.Char (chr, isLower, isPrint, isUpper) |
import Data.Char (chr, isLower, isPrint, isUpper) |
||
import Data.List (partition) |
import Data.List (partition) |
||
import Data.List.Split (chunksOf) |
import Data.List.Split (chunksOf) |
||
----------- ALL LOWERCASE AND UPPERCASE LETTERS ---------- |
----------- ALL LOWERCASE AND UPPERCASE LETTERS ---------- |
||
uppersAndLowers :: (String, String) |
uppersAndLowers :: (String, String) |
||
uppersAndLowers = |
uppersAndLowers = |
||
Line 574: | Line 575: | ||
( partition isUpper $ |
( partition isUpper $ |
||
[1 .. 0x10ffff] |
[1 .. 0x10ffff] |
||
>>= (( |
>>= (((bool [] . pure) <*> isPrint) . chr) |
||
) |
) |
||
--------------------------- TEST ------------------------- |
--------------------------- TEST ------------------------- |
||
main :: IO () |
main :: IO () |