Skip to main content
added 66 characters in body
Source Link
roblogic
  • 4k
  • 18
  • 23

Iterating over the alphabet (or other contiguous ASCII range)

A simple way is to set up 2Iterate over the string variables, and then do a for loop e.g.

var a,c:string;begin
a:='abcdefghijklmnopqrstuvwxyz';for c in a do writeln(c);

But this is more efficient:

var c:char;begin
for c in'abcdefghijklmnopqrstuvwxyz'do writeln(c);

Or even better, use an ASCII range (uppercase alphabet)

var j:word;begin
for j:=65to 90do writeln(chr(j));

BUT! Here's the most compact approach, for 50 bytes:

var j:char;begin for j:=#65to#90do writeln(j)end. 

Iterating over the alphabet (or other contiguous ASCII range)

A simple way is to set up 2 string variables, and then do a for loop e.g.

var a,c:string;begin
a:='abcdefghijklmnopqrstuvwxyz';for c in a do writeln(c);

But this is more efficient:

var c:char;begin
for c in'abcdefghijklmnopqrstuvwxyz'do writeln(c);

Or even better, use an ASCII range (uppercase alphabet)

var j:word;begin
for j:=65to 90do writeln(chr(j));

Iterating over the alphabet (or other contiguous ASCII range)

Iterate over the string:

var c:char;begin
for c in'abcdefghijklmnopqrstuvwxyz'do writeln(c);

Or, use an ASCII range (uppercase alphabet)

var j:word;begin
for j:=65to 90do writeln(chr(j));

BUT! Here's the most compact approach, for 50 bytes:

var j:char;begin for j:=#65to#90do writeln(j)end. 
Source Link
roblogic
  • 4k
  • 18
  • 23

Iterating over the alphabet (or other contiguous ASCII range)

A simple way is to set up 2 string variables, and then do a for loop e.g.

var a,c:string;begin
a:='abcdefghijklmnopqrstuvwxyz';for c in a do writeln(c);

But this is more efficient:

var c:char;begin
for c in'abcdefghijklmnopqrstuvwxyz'do writeln(c);

Or even better, use an ASCII range (uppercase alphabet)

var j:word;begin
for j:=65to 90do writeln(chr(j));