Idiomatically determine all the lowercase and uppercase letters: Difference between revisions
Content added Content deleted
(→{{header|Haskell}}: Used Data.List.Split chunksOf (rather than defining one by hand) for a little more focus.) |
(add FreeBASIC) |
||
Line 202: | Line 202: | ||
ABCDEFGHIJKLMNOPQRSTUVWXYZ |
ABCDEFGHIJKLMNOPQRSTUVWXYZ |
||
abcdefghijklmnopqrstuvwxyz |
abcdefghijklmnopqrstuvwxyz |
||
</pre> |
|||
=={{header|FreeBASIC}}== |
|||
<lang freebasic>enum lettercase |
|||
LOWER = -1, UPPER = 1, NOTLETTER = 0 |
|||
end enum |
|||
function letter_case( ch as string ) as byte |
|||
'exploits the fact that ucase and lcase consider non-letters to be |
|||
'both upper and lower case |
|||
if ucase(ch)=lcase(ch) then return NOTLETTER |
|||
if ch = ucase(ch) then return UPPER |
|||
return LOWER |
|||
end function |
|||
dim as uinteger i |
|||
for i = 0 to 255 |
|||
if letter_case(chr(i)) = LOWER then print chr(i); |
|||
next i |
|||
print |
|||
for i = 0 to 255 |
|||
if letter_case(chr(i)) = UPPER then print chr(i); |
|||
next i |
|||
print</lang> |
|||
{{out}} |
|||
<pre> |
|||
abcdefghijklmnopqrstuvwxyz |
|||
ABCDEFGHIJKLMNOPQRSTUVWXYZ |
|||
</pre> |
</pre> |
||