Idiomatically determine all the lowercase and uppercase letters: Difference between revisions
Idiomatically determine all the lowercase and uppercase letters (view source)
Revision as of 11:09, 10 December 2023
, 5 months ago→{{header|Wren}}: Changed to Wren S/H
imported>Maxima enthusiast No edit summary |
m (→{{header|Wren}}: Changed to Wren S/H) |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 40:
Lower case: abcdefghijklmnopqrstuvwxyz
Upper case: ABCDEFGHIJKLMNOPQRSTUVWXYZ
</pre>
=={{header|8080 Assembly}}==
Code assumes the CP/M operating system and the ASCII character set
<syntaxhighlight>
;------------------------------------------------------
; useful equates
;------------------------------------------------------
bdos equ 5h ; BDOS entry
wboot equ 0 ; BDOS warm boot function
conout equ 2 ; BDOS write character to console function
prtstr equ 9 ; BDOS write string to console function
cr equ 13 ; ASCII carriage return
lf equ 10 ; ASCII line feed
;------------------------------------------------------
; main code begins here
;------------------------------------------------------
org 100h ; entry point under CP/M
lxi sp,stack ; set a local stack
;
; show upper case alphabet
;
lxi d,ucmsg
call message
mvi a,'A'
ucloop: push a
call putchr
pop a
inr a
cpi 'Z'+1
jc ucloop
call crlf
;
; show lower case alphabet
;
lxi d,lcmsg
call message
mvi a,'a'
lcloop: push a
call putchr
pop a
inr a
cpi 'z'+1
jc lcloop
call crlf
;
; we're finished; exit to operating system
;
jmp wboot
;-------------------------------------------------------
; console output of $-terminated string pointed to by DE
;-------------------------------------------------------
message:
push b
push d
push h
mvi c,prtstr
call bdos
pop h
pop d
pop b
ret
;-------------------------------------------------------
; output CRLF to console
;-------------------------------------------------------
crlf: push b
push d
push h
mvi e,cr
mvi c,conout
call bdos
mvi e,lf
mvi c,conout
call bdos
pop h
pop d
pop b
ret
;-------------------------------------------------------
; console output of char in A register
;-------------------------------------------------------
putchr: push b
push d
push h
mov e,a
mvi c,conout
call bdos
pop h
pop d
pop b
ret
;------------------------------------------------------
; messages and data area
;------------------------------------------------------
ucmsg: db 'Upper case: $'
lcmsg: db 'Lower case: $'
stack equ $+128 ; 64-level stack is sufficient
;
end
</syntaxhighlight>
{{out}}
<pre>
Upper case: ABCDEFGHIJKLMNOPQRSTUVWXYZ
Lower case: abcdefghijklmnopqrstuvwxyz
</pre>
Line 525 ⟶ 629:
<pre>Upper case: ABCDEFGHIJKLMNOPQRSTUVWXYZAAAAÄÅÆÇEÉEEIIIIDÑOOOOÖOUUUÜY_AAACCCCDDEEEEEGG...
Lower case: abcdefghijklmnopqrstuvwxyzµßàáâaäåæçèéêëìíîïdñòóôoöoùúûüy_ÿaaaccccddeeee...</pre>
=={{header|EasyLang}}==
<syntaxhighlight lang="easylang">
for i = strcode "a" to strcode "z"
write strchar i
.
print ""
for i = strcode "A" to strcode "Z"
write strchar i
.
</syntaxhighlight>
=={{header|F_Sharp|F#}}==
Line 796 ⟶ 912:
𝜹𝜺𝜻𝜼𝜽𝜾𝜿𝝀𝝁𝝂𝝃𝝄𝝅𝝆𝝇𝝈𝝉𝝊𝝋𝝌𝝍𝝎𝝐𝝑𝝒𝝓𝝔𝝕𝝰𝝱𝝲𝝳𝝴𝝵𝝶𝝷𝝸𝝹𝝺𝝻𝝼𝝽𝝾𝝿𝞀𝞁𝞂𝞃𝞄𝞅𝞆𝞇𝞈𝞊𝞋𝞌𝞍𝞎𝞏𝞪𝞫𝞬𝞭𝞮𝞯𝞰𝞱𝞲𝞳𝞴
𝞵𝞶𝞷𝞸𝞹𝞺𝞻𝞼𝞽𝞾𝞿𝟀𝟁𝟂𝟄𝟅𝟆𝟇𝟈𝟉𝟋</pre>
=={{Header|Insitux}}==
<b>Approach One</b>
<syntaxhighlight lang="insitux">
(let chars-between (comp range (map char-code) (... str)))
(str "Upper-case: " (chars-between 65 91) "
Lower-case: " (chars-between 97 123))
</syntaxhighlight>
<b>Approach Two</b>
<syntaxhighlight lang="insitux">
(let ascii (map char-code (range 127)))
(.. str "Upper-case: " (filter upper? ascii) "
Lower-case: " (filter lower? ascii))
</syntaxhighlight>
{{out}}
for both approaches
<pre>
Upper-case: ABCDEFGHIJKLMNOPQRSTUVWXYZ
Lower-case: abcdefghijklmnopqrstuvwxyz
</pre>
=={{header|J}}==
Line 1,283 ⟶ 1,427:
=={{header|S-BASIC}}==
S-BASIC has been implemented only for computers using the Z80 CPU and the CP/M operating system and only
supports the ASCII character set. In S-BASIC,
may be treated in most contexts simply as small integers, avoiding the
such as ASC() and CHR$() needed in many other BASIC dialects (though S-BASIC does support them also).
<syntaxhighlight lang = "BASIC")>
var c = byte
print "Upper Case: ";
Line 1,311 ⟶ 1,450:
Lower Case: abcdefghijklmnopqrstuvwxyz
</pre>
=={{header|Scala}}==
Line 1,342 ⟶ 1,480:
=={{header|Wren}}==
Wren doesn't have a separate character class but it is easy enough to generate the lower and upper case Latin alphabet from the raw bytes.
<syntaxhighlight lang="
System.print()
for (i in 65..90) System.write(String.fromByte(i))
|