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

m
→‎{{header|Wren}}: Changed to Wren S/H
(Idiomatically determine all the lowercase and uppercase letters in Dart)
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(12 intermediate revisions by 11 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 165 ⟶ 269:
uppercase 60: ABCDEFGHIJKLMNOPQRSTUVWXYZSOZYAAAAÄÅÆÇEÉEEIIIIDÑOOOOÖOUUUÜY_
</pre>
 
=={{header|BASIC}}==
==={{header|Applesoft BASIC}}===
{{works with|Chipmunk Basic}}
{{works with|GW-BASIC}}
<syntaxhighlight lang="qbasic">10 FOR j = ASC("a") TO ASC("z")
20 PRINT CHR$(j);
30 NEXT j
40 PRINT
50 FOR j = ASC("A") TO ASC("Z")
60 PRINT CHR$(j);
70 NEXT j
80 END</syntaxhighlight>
{{out}}
<pre>abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ</pre>
 
==={{header|BASIC256}}===
<syntaxhighlight lang="vb">for j = asc("a") to asc("z")
print chr(j);
next j
print
for j= asc("A") to Asc("Z")
print chr(j);
next j
end</syntaxhighlight>
{{out}}
<pre>abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ</pre>
 
==={{header|Chipmunk Basic}}===
{{works with|Chipmunk Basic|3.6.4}}
{{works with|Applesoft BASIC}}
{{works with|GW-BASIC}}
{{works with|QBasic}}
<syntaxhighlight lang="qbasic">10 FOR j = ASC("a") TO ASC("z")
20 PRINT CHR$(j);
30 NEXT j
40 PRINT
50 FOR j = ASC("A") TO ASC("Z")
60 PRINT CHR$(j);
70 NEXT j
80 END</syntaxhighlight>
 
==={{header|GW-BASIC}}===
{{works with|Applesoft BASIC}}
{{works with|Chipmunk Basic}}
{{works with|QBasic}}
<syntaxhighlight lang="qbasic">10 FOR j = ASC("a") TO ASC("z")
20 PRINT CHR$(j);
30 NEXT j
40 PRINT
50 FOR j = ASC("A") TO ASC("Z")
60 PRINT CHR$(j);
70 NEXT j
80 END</syntaxhighlight>
{{out}}
<pre>abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ</pre>
 
==={{header|QBasic}}===
{{works with|QBasic|1.1}}
{{works with|QuickBasic|4.5}}
{{works with|Applesoft BASIC}}
{{works with|Chipmunk Basic}}
{{works with|GW-BASIC}}
<syntaxhighlight lang="qbasic">10 CLS : REM 10 HOME for Applesoft BASIC
20 FOR J = ASC("a") TO ASC("z")
30 PRINT CHR$(J);
40 NEXT J
50 PRINT
60 FOR J = ASC("A") TO ASC("Z")
70 PRINT CHR$(J);
80 NEXT J
90 END</syntaxhighlight>
{{out}}
<pre>abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ</pre>
 
==={{header|Run BASIC}}===
{{works with|Just BASIC}}
{{works with|Liberty BASIC}}
{{works with|Yabasic}}
<syntaxhighlight lang="vb">for j = asc("a") to asc("z")
print chr$(j);
next j
print
for j = asc("A") to asc("Z")
print chr$(j);
next j
end</syntaxhighlight>
{{out}}
<pre>abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ</pre>
 
==={{header|True BASIC}}===
<syntaxhighlight lang="qbasic">FOR j = ORD("a"[1:1]) TO ORD("z"[1:1])
PRINT CHR$(j);
NEXT j
PRINT
FOR j = ORD("A"[1:1]) to ORD("Z"[1:1])
PRINT CHR$(j);
NEXT j
END</syntaxhighlight>
{{out}}
<pre>abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ</pre>
 
==={{header|Yabasic}}===
{{works with|Just BASIC}}
{{works with|Liberty BASIC}}
{{works with|Run BASIC}}
<syntaxhighlight lang="vb">for j = asc("a") to asc("z")
print chr$(j);
next j
print
for j= asc("A") to asc("Z")
print chr$(j);
next j
end</syntaxhighlight>
{{out}}
<pre>abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ</pre>
 
=={{header|C}}==
Line 402 ⟶ 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 453 ⟶ 692:
ABCDEFGHIJKLMNOPQRSTUVWXYZ
</pre>
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
int i
 
for i = asc("a") to asc("z") : print chr$(i); : next
print
for i = asc("A") to asc("Z") : print chr$(i); : next
 
HandleEvents
</syntaxhighlight>
{{output}}
<pre>
abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ
</pre>
 
 
=={{header|Go}}==
Line 656 ⟶ 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 670 ⟶ 954:
<syntaxhighlight lang="j"> (#~ tolower ~: toupper) u: i.65536
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz</syntaxhighlight>
 
=={{header|Jakt}}==
<syntaxhighlight lang="jakt">
fn main() {
mut lower = StringBuilder::create()
// Iteration as code points (u32)
for code_point in 'a'..('z' + 1) {
lower.append(code_point)
}
println("{}", lower.to_string())
 
mut upper = StringBuilder::create()
// Iteration as ASCII bytes (u8), same result
for b in b'A'..(b'Z' + 1) {
upper.append(b)
}
println("{}", upper.to_string())
}
</syntaxhighlight>
 
=={{header|Java}}==
Line 803 ⟶ 1,106:
<pre>abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ</pre>
 
=={{header|Maxima}}==
<syntaxhighlight lang="maxima">
sublist(makelist(unicode(i),i,0,127),lowercasep);
sublist(makelist(unicode(i),i,0,127),uppercasep);
</syntaxhighlight>
{{out}}
<pre>
["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
</pre>
 
=={{header|MiniScript}}==
Line 823 ⟶ 1,137:
Nim has a <code>char</code> type whose values are contained in a single bit. The values from 0 to 127 are the ASCII characters. Strings are composed of char values but they are considered to be encoded in UTF-8. So accessing an individual character of a string may have no meaning when not working in ASCII.
 
The following program displays the lowercase and uppercase letters. Note that Nim allows to work with full Unicode, either by using strings encoded in UTF-8 (but with limited possibilities) or by using the runes of the module “unicode”. Identifiers may contain Unicode letters or digits as in “θ₁”, “â”, “x₁”, “x³”.
 
The following program displays the lowercase and uppercase ASCII letters.
 
<syntaxhighlight lang="nim">import sequtils, strutils
Line 847 ⟶ 1,163:
 
=={{header|Perl}}==
<syntaxhighlight lang="perl">foruse $i (0v5..2**8-1) {12;
use utf8;
$c = chr $i;
binmode STDOUT, ':utf8';
 
my($lower,$upper);
 
for my $i (0..2**8-1) {
my $c = chr $i;
$lower .= $c if $c =~ /[[:lower:]]/;
$upper .= $c if $c =~ /[[:upper:]]/;
}
 
printsay "$lower\n";
printsay "$upper\n";</syntaxhighlight>
{{out}}
<pre>abcdefghijklmnopqrstuvwxyzªµºßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ
ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ</pre>
ABCDEFGHIJKLMNOPQRSTUVWXYZ</pre>
 
=={{header|Phix}}==
Line 1,063 ⟶ 1,385:
Lower case : abcdefghijklmnopqrstuvwxyz
Upper case : ABCDEFGHIJKLMNOPQRSTUVWXYZ
 
=={{header|RPL}}==
RPL use a proprietary set of 8-bit characters, which coding system matches with ASCII from space (ASCII 32) to tilde (ASCII 126).
≪ "" "A" NUM "Z" NUM '''FOR''' c c CHR + '''NEXT'''
"" "a" NUM "z" NUM '''FOR''' c c CHR + '''NEXT'''
≫ EVAL
{{out}}
<pre>
2: "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
1: "abcdefghijklmnopqrstuvwxyz"
</pre>
 
=={{header|Ruby}}==
Line 1,090 ⟶ 1,423:
Lowercase letters: abcdefghijklmnopqrstuvwxyz
Uppercase letters: ABCDEFGHIJKLMNOPQRSTUVWXYZ
</pre>
 
=={{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, CHAR is equivalent to BYTE, and variables declared as such
may be treated in most contexts simply as small integers, avoiding the need to use conversion functions
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: ";
for c = 'A' to 'Z'
print c;
next c
print
print "Lower Case: ";
for c = 'a' to 'z'
print c;
next c
print
 
end
</syntaxhighlight>
{{out}}
<pre>
Upper Case: ABCDEFGHIJKLMNOPQRSTUVWXYZ
Lower Case: abcdefghijklmnopqrstuvwxyz
</pre>
 
Line 1,121 ⟶ 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="ecmascriptwren">for (i in 97..122) System.write(String.fromByte(i))
System.print()
for (i in 65..90) System.write(String.fromByte(i))
9,476

edits