Generate lower case ASCII alphabet: Difference between revisions

+ Ada and D entries
(First draft of the task)
 
(+ Ada and D entries)
Line 3:
 
If the standard library contains such sequence, show how to access it, but don't fail to show how to generate a similar sequence. For this basic task use a reliable style of coding, a style fit for a large program, and use strong typing if available.
 
=={{header|Ada}}==
<lang ada>procedure Alphabet is
type Arr_Type is array (Integer range <>) of Character;
Arr : Arr_Type (1 .. 26);
C : Character := 'a';
begin
for I in Arr'Range loop
Arr (I) := C;
C := Character'Succ (C);
end loop;
end;</lang>
 
=={{header|D}}==
The lower case ASCII letters of the Phobos standard library:
<lang d>import std.ascii: lowercase;
 
void main() {}</lang>
 
The generation of the ASCII alphabet array:
<lang d>void main() {
char[26] arr;
 
foreach (immutable i, ref c; arr)
// c = 'a' + i;
c = cast(char)('a' + i);
}</lang>
 
An alternative version:
<lang d>import std.range, std.algorithm, std.array;
 
void main() {
char[26] arr = 26
.iota
.map!(i => cast(char)('a' + i))
.array;
}</lang>