Generate lower case ASCII alphabet: Difference between revisions
m →{{header|Ring}}: simplified |
→Nu: add |
||
(36 intermediate revisions by 30 users not shown) | |||
Line 7: | Line 7: | ||
During code review it's not immediate obvious to spot the bug in a Tcl line like this contained in a page of code: |
During code review it's not immediate obvious to spot the bug in a Tcl line like this contained in a page of code: |
||
< |
<syntaxhighlight lang="tcl">set alpha {a b c d e f g h i j k m n o p q r s t u v w x y z}</syntaxhighlight> |
||
Line 15: | Line 15: | ||
=={{header|0815}}== |
=={{header|0815}}== |
||
This creates the list in the queue |
This creates the list in the queue |
||
< |
<syntaxhighlight lang="0815"><:61:~}:000:>>&{~<:7a:-#:001:<:1:+^:000:</syntaxhighlight> |
||
=={{header|11l}}== |
=={{header|11l}}== |
||
<lang |
<syntaxhighlight lang="11l">print(Array(‘a’..‘z’))</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 27: | Line 27: | ||
In EBCDIC coding there are more than 24 characters between a and z. |
In EBCDIC coding there are more than 24 characters between a and z. |
||
So we have to get rid of characters between i and j and also between r and s. |
So we have to get rid of characters between i and j and also between r and s. |
||
< |
<syntaxhighlight lang="360asm">* Generate lower case alphabet - 15/10/2015 |
||
LOWER CSECT |
LOWER CSECT |
||
USING LOWER,R15 set base register |
USING LOWER,R15 set base register |
||
Line 54: | Line 54: | ||
PG DS CL26 buffer |
PG DS CL26 buffer |
||
YREGS |
YREGS |
||
END LOWER</ |
END LOWER</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 62: | Line 62: | ||
=={{header|6502 Assembly}}== |
=={{header|6502 Assembly}}== |
||
Stores the lower-case ASCII alphabet as a null-terminated string beginning at address 2000 hex. Register contents are preserved. |
Stores the lower-case ASCII alphabet as a null-terminated string beginning at address 2000 hex. Register contents are preserved. |
||
< |
<syntaxhighlight lang="asm6502">ASCLOW: PHA ; push contents of registers that we |
||
TXA ; shall be using onto the stack |
TXA ; shall be using onto the stack |
||
PHA |
PHA |
||
Line 78: | Line 78: | ||
TAX ; the stack |
TAX ; the stack |
||
PLA |
PLA |
||
RTS ; return</ |
RTS ; return</syntaxhighlight> |
||
=={{header|68000 Assembly}}== |
=={{header|68000 Assembly}}== |
||
Line 88: | Line 88: | ||
Called as a subroutine (i.e. "JSR Ascii_Low" if far away or "BSR Ascii_Low" if nearby) |
Called as a subroutine (i.e. "JSR Ascii_Low" if far away or "BSR Ascii_Low" if nearby) |
||
< |
<syntaxhighlight lang="68000devpac"> |
||
Ascii_Low: |
Ascii_Low: |
||
MOVEM.L D0/A0,-(SP) ;store D0 and A0 on stack |
MOVEM.L D0/A0,-(SP) ;store D0 and A0 on stack |
||
Line 105: | Line 105: | ||
rts |
rts |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|8080 Assembly}}== |
=={{header|8080 Assembly}}== |
||
Line 112: | Line 112: | ||
in the form of an <code>$</code>-terminated string that CP/M syscalls can use. |
in the form of an <code>$</code>-terminated string that CP/M syscalls can use. |
||
< |
<syntaxhighlight lang="8080asm"> org 100h |
||
jmp test |
jmp test |
||
Line 141: | Line 141: | ||
buf: ds 27 ; buffer to keep the alphabet in |
buf: ds 27 ; buffer to keep the alphabet in |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|8086 Assembly}}== |
=={{header|8086 Assembly}}== |
||
< |
<syntaxhighlight lang="asm"> bits 16 |
||
cpu 8086 |
cpu 8086 |
||
org 100h |
org 100h |
||
Line 169: | Line 169: | ||
ret |
ret |
||
section .bss |
section .bss |
||
buf: resb 27 ; Buffer to store the alphabet in</ |
buf: resb 27 ; Buffer to store the alphabet in</syntaxhighlight> |
||
=={{header|8th}}== |
=={{header|8th}}== |
||
We take an empty string, and use the "loop" word to create a new character using "'a n:+". The loop passes the current index to the code being iterated, so it starts with 0 and up to 25, adding to the "'a" - which is the numeric value of lowercase "a", and the resultant number is then appended to the string. That converts the number to the appropriate character and appends it: |
We take an empty string, and use the "loop" word to create a new character using "'a n:+". The loop passes the current index to the code being iterated, so it starts with 0 and up to 25, adding to the "'a" - which is the numeric value of lowercase "a", and the resultant number is then appended to the string. That converts the number to the appropriate character and appends it: |
||
< |
<syntaxhighlight lang="forth"> |
||
"" ( 'a n:+ s:+ ) 0 25 loop |
"" ( 'a n:+ s:+ ) 0 25 loop |
||
. cr |
. cr |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 184: | Line 184: | ||
=={{header|ABAP}}== |
=={{header|ABAP}}== |
||
=== Example with simple write statement === |
=== Example with simple write statement === |
||
< |
<syntaxhighlight lang="abap">REPORT lower_case_ascii. |
||
WRITE: / to_lower( sy-abcde ).</ |
WRITE: / to_lower( sy-abcde ).</syntaxhighlight> |
||
=== Example with / without space using CL_DEMO_OUTPUT class === |
=== Example with / without space using CL_DEMO_OUTPUT class === |
||
< |
<syntaxhighlight lang="abap">REPORT lower_case_ascii. |
||
cl_demo_output=>new( |
cl_demo_output=>new( |
||
Line 198: | Line 198: | ||
ELSE |{ out } { COND string( WHEN char <> strlen( sy-abcde ) THEN sy-abcde+char(1) ) }| ) ) |
ELSE |{ out } { COND string( WHEN char <> strlen( sy-abcde ) THEN sy-abcde+char(1) ) }| ) ) |
||
)->write( |Or use the system field: { sy-abcde }| |
)->write( |Or use the system field: { sy-abcde }| |
||
)->display( ).</ |
)->display( ).</syntaxhighlight> |
||
=={{header|Action!}}== |
=={{header|Action!}}== |
||
< |
<syntaxhighlight lang="action!">byte X |
||
Proc Main() |
Proc Main() |
||
Line 210: | Line 210: | ||
Od |
Od |
||
Return</ |
Return</syntaxhighlight> |
||
{{Out}} |
{{Out}} |
||
<pre>abcdefghijklmnopqrstuvwxyz</pre> |
<pre>abcdefghijklmnopqrstuvwxyz</pre> |
||
Line 218: | Line 218: | ||
We start with a strong type definition: A character range that can only hold lower-case letters: |
We start with a strong type definition: A character range that can only hold lower-case letters: |
||
< |
<syntaxhighlight lang="ada"> type Lower_Case is new Character range 'a' .. 'z';</syntaxhighlight> |
||
Now we define an array type and initialize the Array A of that type with the 26 letters: |
Now we define an array type and initialize the Array A of that type with the 26 letters: |
||
< |
<syntaxhighlight lang="ada"> type Arr_Type is array (Integer range <>) of Lower_Case; |
||
A : Arr_Type (1 .. 26) := "abcdefghijklmnopqrstuvwxyz";</ |
A : Arr_Type (1 .. 26) := "abcdefghijklmnopqrstuvwxyz";</syntaxhighlight> |
||
Strong typing would catch two errors: (1) any upper-case letters or other symbols in the string assigned to A, and (2) too many or too few letters assigned to A. However, a letter might still appear twice (or more) in A, at the cost of one or more other letters. Array B is safe even against such errors: |
Strong typing would catch two errors: (1) any upper-case letters or other symbols in the string assigned to A, and (2) too many or too few letters assigned to A. However, a letter might still appear twice (or more) in A, at the cost of one or more other letters. Array B is safe even against such errors: |
||
< |
<syntaxhighlight lang="ada"> B : Arr_Type (1 .. 26); |
||
begin |
begin |
||
B(B'First) := 'a'; |
B(B'First) := 'a'; |
||
for I in B'First .. B'Last-1 loop |
for I in B'First .. B'Last-1 loop |
||
B(I+1) := Lower_Case'Succ(B(I)); |
B(I+1) := Lower_Case'Succ(B(I)); |
||
end loop; -- now all the B(I) are different</ |
end loop; -- now all the B(I) are different</syntaxhighlight> |
||
=={{header|ALGOL 68}}== |
=={{header|ALGOL 68}}== |
||
{{works with|ALGOL 68G|Any - tested with release 2.6.win32}} |
{{works with|ALGOL 68G|Any - tested with release 2.6.win32}} |
||
< |
<syntaxhighlight lang="algol68"> # in ALGOL 68, a STRING is an array of characters with flexible bounds # |
||
# so we can declare an array of 26 characters and assign a string # |
# so we can declare an array of 26 characters and assign a string # |
||
# containing the lower-case letters to it # |
# containing the lower-case letters to it # |
||
[ 26 ]CHAR lc := "abcdefghijklmnopqrstuvwxyz" |
[ 26 ]CHAR lc := "abcdefghijklmnopqrstuvwxyz" |
||
</syntaxhighlight> |
|||
</lang> |
|||
Alternative version |
Alternative version |
||
< |
<syntaxhighlight lang="algol68"> # fills lc with the 26 lower-case letters, assuming that # |
||
# they are consecutive in the character set, as they are in ASCII # |
# they are consecutive in the character set, as they are in ASCII # |
||
Line 250: | Line 250: | ||
DO |
DO |
||
lc[ i ] := REPR ( ABS "a" + ( i - 1 ) ) |
lc[ i ] := REPR ( ABS "a" + ( i - 1 ) ) |
||
OD</ |
OD</syntaxhighlight> |
||
=={{header|ALGOL W}}== |
=={{header|ALGOL W}}== |
||
< |
<syntaxhighlight lang="algolw"> % set lc to the lower case alphabet % |
||
string(26) lc; |
string(26) lc; |
||
for c := 0 until 25 do lc( c // 1 ) := code( decode( "a" ) + c );</ |
for c := 0 until 25 do lc( c // 1 ) := code( decode( "a" ) + c );</syntaxhighlight> |
||
=={{header|APL}}== |
=={{header|APL}}== |
||
{{works with|Dyalog APL}} |
{{works with|Dyalog APL}} |
||
< |
<syntaxhighlight lang="apl"> ⎕UCS 96+⍳26</syntaxhighlight> |
||
=={{header|AppleScript}}== |
=={{header|AppleScript}}== |
||
< |
<syntaxhighlight lang="applescript">-------------------- ALPHABETIC SERIES ------------------- |
||
on run |
on run |
||
unlines(map(concat, ¬ |
unlines(map(concat, ¬ |
||
Line 354: | Line 354: | ||
set my text item delimiters to dlm |
set my text item delimiters to dlm |
||
s |
s |
||
end unlines</ |
end unlines</syntaxhighlight> |
||
{{Out}} |
{{Out}} |
||
<pre>abcdefghijklmnopqrstuvwxyz |
<pre>abcdefghijklmnopqrstuvwxyz |
||
Line 363: | Line 363: | ||
A minor variation would be to perform a mass conversion and character extraction at the end instead of twenty-six individual <tt>character id i</tt> conversions: |
A minor variation would be to perform a mass conversion and character extraction at the end instead of twenty-six individual <tt>character id i</tt> conversions: |
||
< |
<syntaxhighlight lang="applescript">set l to {} |
||
repeat with i from id of "a" to id of "z" |
repeat with i from id of "a" to id of "z" |
||
set end of l to i |
set end of l to i |
||
end repeat |
end repeat |
||
return characters of string id l</ |
return characters of string id l</syntaxhighlight> |
||
{{Out}} |
{{Out}} |
||
< |
<syntaxhighlight lang="applescript">{"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"}</syntaxhighlight> |
||
=={{header|Applesoft BASIC}}== |
=={{header|Applesoft BASIC}}== |
||
< |
<syntaxhighlight lang="applesoftbasic">L$="abcdefghijklmnopqrstuvwxyz"</syntaxhighlight> |
||
On the older model Apple II and Apple II plus, it is difficult to enter lower case characters. The following code generates the same string: |
On the older model Apple II and Apple II plus, it is difficult to enter lower case characters. The following code generates the same string: |
||
< |
<syntaxhighlight lang="applesoftbasic">L$="":FORI=1TO26:L$=L$+CHR$(96+I):NEXT</syntaxhighlight> |
||
=={{header|ARM Assembly}}== |
=={{header|ARM Assembly}}== |
||
Line 385: | Line 385: | ||
This code generates the lower case ASCII set, stores it in RAM as a string literal, and prints that string to the screen. |
This code generates the lower case ASCII set, stores it in RAM as a string literal, and prints that string to the screen. |
||
< |
<syntaxhighlight lang="arm assembly">ProgramStart: |
||
mov sp,#0x03000000 ;Init Stack Pointer |
mov sp,#0x03000000 ;Init Stack Pointer |
||
Line 410: | Line 410: | ||
forever: |
forever: |
||
b forever ;halt the cpu</ |
b forever ;halt the cpu</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
[https://ibb.co/4SbsgzP Picture of output] |
[https://ibb.co/4SbsgzP Picture of output] |
||
Line 416: | Line 416: | ||
=={{header|Arturo}}== |
=={{header|Arturo}}== |
||
< |
<syntaxhighlight lang="rebol">print to [:char] 97..122</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 422: | Line 422: | ||
=={{header|ATS}}== |
=={{header|ATS}}== |
||
<syntaxhighlight lang="ats"> |
|||
<lang ATS> |
|||
(* ****** ****** *) |
(* ****** ****** *) |
||
// |
// |
||
Line 449: | Line 449: | ||
// |
// |
||
} (* end of [main0] *) |
} (* end of [main0] *) |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|AutoHotkey}}== |
=={{header|AutoHotkey}}== |
||
{{works with|AutoHotkey 1.1}} |
{{works with|AutoHotkey 1.1}} |
||
< |
<syntaxhighlight lang="autohotkey">a :={} |
||
Loop, 26 |
Loop, 26 |
||
a.Insert(Chr(A_Index + 96))</ |
a.Insert(Chr(A_Index + 96))</syntaxhighlight> |
||
=={{header|AutoIt}}== |
=={{header|AutoIt}}== |
||
<syntaxhighlight lang="autoit"> |
|||
<lang AutoIt> |
|||
Func _a2z() |
Func _a2z() |
||
Local $a2z = "" |
Local $a2z = "" |
||
Line 466: | Line 466: | ||
Return $a2z |
Return $a2z |
||
EndFunc |
EndFunc |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|AWK}}== |
=={{header|AWK}}== |
||
Line 475: | Line 475: | ||
Note this is dependent on the locale-setting, |
Note this is dependent on the locale-setting, |
||
and options, e.g. --traditional and --posix |
and options, e.g. --traditional and --posix |
||
<syntaxhighlight lang="awk"> |
|||
<lang AWK> |
|||
# syntax: GAWK -f GENERATE_LOWER_CASE_ASCII_ALPHABET.AWK |
# syntax: GAWK -f GENERATE_LOWER_CASE_ASCII_ALPHABET.AWK |
||
BEGIN { |
BEGIN { |
||
Line 487: | Line 487: | ||
exit(0) |
exit(0) |
||
} |
} |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{Output}} |
{{Output}} |
||
<pre> |
<pre> |
||
Line 496: | Line 496: | ||
=={{header|BASIC}}== |
=={{header|BASIC}}== |
||
==={{header|BBC BASIC}}=== |
==={{header|BBC BASIC}}=== |
||
< |
<syntaxhighlight lang="bbcbasic"> DIM lower&(25) |
||
FOR i%=0TO25 |
FOR i%=0TO25 |
||
lower&(i%)=ASC"a"+i% |
lower&(i%)=ASC"a"+i% |
||
NEXT |
NEXT |
||
END</ |
END</syntaxhighlight> |
||
==={{header|BASIC256}}=== |
==={{header|BASIC256}}=== |
||
< |
<syntaxhighlight lang="basic256"> |
||
# generate lowercase ascii alphabet |
# generate lowercase ascii alphabet |
||
# basic256 1.1.4.0 |
# basic256 1.1.4.0 |
||
Line 513: | Line 513: | ||
print a$[i] + " "; |
print a$[i] + " "; |
||
next i |
next i |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 520: | Line 520: | ||
==={{header|Commodore BASIC}}=== |
==={{header|Commodore BASIC}}=== |
||
< |
<syntaxhighlight lang="gwbasic">10 FOR I=ASC("A") TO ASC("Z") |
||
20 A$ = A$+CHR$(I) |
20 A$ = A$+CHR$(I) |
||
30 NEXT |
30 NEXT |
||
40 PRINT CHR$(14) : REM 'SWITCH CHARACTER SET TO LOWER/UPPER CASES |
40 PRINT CHR$(14) : REM 'SWITCH CHARACTER SET TO LOWER/UPPER CASES |
||
50 PRINT A$</ |
50 PRINT A$</syntaxhighlight> |
||
==={{header|FreeBASIC}}=== |
==={{header|FreeBASIC}}=== |
||
< |
<syntaxhighlight lang="freebasic">' FB 1.05.0 Win64 |
||
' Create a string buffer to store the alphabet plus a final null byte |
' Create a string buffer to store the alphabet plus a final null byte |
||
Line 541: | Line 541: | ||
Print "Press any key to quit" |
Print "Press any key to quit" |
||
Sleep |
Sleep |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{out}} |
{{out}} |
||
Line 549: | Line 549: | ||
==={{header|IS-BASIC}}=== |
==={{header|IS-BASIC}}=== |
||
< |
<syntaxhighlight lang="is-basic">100 STRING ALPHA$*26 |
||
110 LET ALPHA$="" |
110 LET ALPHA$="" |
||
120 FOR I=ORD("a") TO ORD("z") |
120 FOR I=ORD("a") TO ORD("z") |
||
130 LET ALPHA$=ALPHA$&CHR$(I) |
130 LET ALPHA$=ALPHA$&CHR$(I) |
||
140 NEXT |
140 NEXT |
||
150 PRINT ALPHA$</ |
150 PRINT ALPHA$</syntaxhighlight> |
||
==={{header|PureBasic}}=== |
==={{header|PureBasic}}=== |
||
< |
<syntaxhighlight lang="purebasic">Dim lower_case('z' - 'a') ;indexing goes from 0 -> 25 |
||
For i = 0 To ArraySize(lower_case()) |
For i = 0 To ArraySize(lower_case()) |
||
lower_case(i) = i + 'a' |
lower_case(i) = i + 'a' |
||
Next</ |
Next</syntaxhighlight> |
||
==={{header|QBasic}}=== |
|||
{{works with|QBasic|1.1}} |
|||
{{works with|QuickBasic|4.5}} |
|||
{{works with|True BASIC}} |
|||
<syntaxhighlight lang="qbasic">DIM a$(27) |
|||
FOR i = 1 to 26 |
|||
LET a$(i) = CHR$(i + 96) |
|||
PRINT a$(i); |
|||
NEXT i |
|||
END</syntaxhighlight> |
|||
==={{header|True BASIC}}=== |
|||
{{works with|QBasic|1.1}} |
|||
{{works with|QuickBasic|4.5}} |
|||
<syntaxhighlight lang="qbasic">DIM a$(27) |
|||
FOR i = 1 to 26 |
|||
LET a$(i) = CHR$(i + 96) |
|||
PRINT a$(i); |
|||
NEXT i |
|||
END</syntaxhighlight> |
|||
==={{header|XBasic}}=== |
|||
{{works with|Windows XBasic}} |
|||
<syntaxhighlight lang="qbasic">PROGRAM "progname" |
|||
VERSION "0.0000" |
|||
DECLARE FUNCTION Entry () |
|||
FUNCTION Entry () |
|||
DIM a$[27] |
|||
FOR i = 1 TO 26 |
|||
a$[i] = CHR$(i + 96) |
|||
PRINT a$[i]; |
|||
NEXT i |
|||
END FUNCTION |
|||
END PROGRAM</syntaxhighlight> |
|||
==={{header|Yabasic}}=== |
|||
{{works with|QBasic|1.1}} |
|||
{{works with|QuickBasic|4.5}} |
|||
{{works with|Run BASIC}} |
|||
<syntaxhighlight lang="yabasic">for i = asc("a") to asc("z") |
|||
print chr$(i); |
|||
next i</syntaxhighlight> |
|||
==={{header|Run BASIC}}=== |
==={{header|Run BASIC}}=== |
||
< |
<syntaxhighlight lang="runbasic">for i = asc("a") to asc("z") |
||
print chr$(i); |
print chr$(i); |
||
next i</ |
next i</syntaxhighlight>Output: |
||
<pre>abcdefghijklmnopqrstuvwxyz</pre> |
<pre>abcdefghijklmnopqrstuvwxyz</pre> |
||
==={{header|uBasic/4tH}}=== |
==={{header|uBasic/4tH}}=== |
||
<lang>For x= ORD("a") To ORD("z") : @(x - ORD("a")) = x : Next</ |
<syntaxhighlight lang="text">For x= ORD("a") To ORD("z") : @(x - ORD("a")) = x : Next</syntaxhighlight> |
||
==={{header|ZX Spectrum Basic}}=== |
==={{header|ZX Spectrum Basic}}=== |
||
{{trans|BBC_BASIC}} |
{{trans|BBC_BASIC}} |
||
< |
<syntaxhighlight lang="zxbasic">10 DIM l$(26): LET init= CODE "a"-1 |
||
20 FOR i=1 TO 26 |
20 FOR i=1 TO 26 |
||
30 LET l$(i)=CHR$ (init+i) |
30 LET l$(i)=CHR$ (init+i) |
||
40 NEXT i |
40 NEXT i |
||
50 PRINT l$</ |
50 PRINT l$</syntaxhighlight> |
||
==={{header|BaCon}}=== |
==={{header|BaCon}}=== |
||
Using the inline loop construct. |
Using the inline loop construct. |
||
< |
<syntaxhighlight lang="bacon">PRINT LOOP$(26, CHR$(96+_))</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>abcdefghijklmnopqrstuvwxyz</pre> |
<pre>abcdefghijklmnopqrstuvwxyz</pre> |
||
=={{header|Batch File}}== |
=={{header|Batch File}}== |
||
< |
<syntaxhighlight lang="dos"> |
||
@echo off |
@echo off |
||
setlocal enabledelayedexpansion |
setlocal enabledelayedexpansion |
||
Line 598: | Line 647: | ||
echo %alphabet% |
echo %alphabet% |
||
pause>nul |
pause>nul |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 606: | Line 655: | ||
=={{header|Befunge}}== |
=={{header|Befunge}}== |
||
The left hand side pushes the sequence 'a' to 'z' onto the stack in reverse order with a null terminator (a fairly typical Befunge pattern). The right hand side is just printing it out again to test. |
The left hand side pushes the sequence 'a' to 'z' onto the stack in reverse order with a null terminator (a fairly typical Befunge pattern). The right hand side is just printing it out again to test. |
||
< |
<syntaxhighlight lang="befunge">0"z":>"a"`#v_ >:#,_$@ |
||
^:- 1:<</ |
^:- 1:<</syntaxhighlight> |
||
=={{header|BQN}}== |
=={{header|BQN}}== |
||
<lang |
<syntaxhighlight lang="bqn">'a'+↕26</syntaxhighlight> |
||
=={{header|Bracmat}}== |
=={{header|Bracmat}}== |
||
< |
<syntaxhighlight lang="bracmat"> a:?seq:?c |
||
& whl |
& whl |
||
' ( chr$(asc$!c+1):~>z:?c |
' ( chr$(asc$!c+1):~>z:?c |
||
& !seq !c:?seq |
& !seq !c:?seq |
||
) |
) |
||
& !seq</ |
& !seq</syntaxhighlight> |
||
=={{header|Brainf***}}== |
=={{header|Brainf***}}== |
||
< |
<syntaxhighlight lang="bf">Make room for 26 characters |
||
>>>>>>>>>>>>> |
>>>>>>>>>>>>> |
||
>>>>>>>>>>>>> |
>>>>>>>>>>>>> |
||
Line 647: | Line 696: | ||
Print each cell |
Print each cell |
||
>[.>] |
>[.>] |
||
++++++++++. \n</ |
++++++++++. \n</syntaxhighlight> |
||
Uncommented: |
Uncommented: |
||
< |
<syntaxhighlight lang="bf">>>>>>>>>>>>>>>>>>>>>>>>>>>>>++++++++++++++++++++++++++[-<<[+<] |
||
+[>]>]<<[+++++++++++++++++++++++++++++++++++++++++++++++++++++ |
+[>]>]<<[+++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
+++++++++++++++++++++++++++++++++++++++++++<]>[.>]++++++++++.</ |
+++++++++++++++++++++++++++++++++++++++++++<]>[.>]++++++++++.</syntaxhighlight> |
||
A smaller and faster solution: |
A smaller and faster solution: |
||
< |
<syntaxhighlight lang="bf">++++++++++++++++++++++++++ > |
||
++++++++++++++++++++++++++ ++++++ |
++++++++++++++++++++++++++ ++++++ |
||
++++++++++++++++++++++++++ ++++++ |
++++++++++++++++++++++++++ ++++++ |
||
++++++++++++++++++++++++++ ++++++ |
++++++++++++++++++++++++++ ++++++ |
||
< [ - > + . < ]</ |
< [ - > + . < ]</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 666: | Line 715: | ||
=={{header|Burlesque}}== |
=={{header|Burlesque}}== |
||
< |
<syntaxhighlight lang="burlesque">blsq ) @azr\sh |
||
abcdefghijklmnopqrstuvwxyz</ |
abcdefghijklmnopqrstuvwxyz</syntaxhighlight> |
||
=={{header|C}}== |
=={{header|C}}== |
||
< |
<syntaxhighlight lang="c">#include <stdlib.h> |
||
#define N 26 |
#define N 26 |
||
Line 683: | Line 732: | ||
return EXIT_SUCCESS; |
return EXIT_SUCCESS; |
||
} |
} |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|C sharp}}== |
=={{header|C sharp}}== |
||
Simple Linq 1 liner solution |
Simple Linq 1 liner solution |
||
< |
<syntaxhighlight lang="csharp">using System; |
||
using System.Linq; |
using System.Linq; |
||
Line 696: | Line 745: | ||
Console.WriteLine(String.Concat(Enumerable.Range('a', 26).Select(c => (char)c))); |
Console.WriteLine(String.Concat(Enumerable.Range('a', 26).Select(c => (char)c))); |
||
} |
} |
||
}</ |
}</syntaxhighlight>{{Output}}<pre>abcdefghijklmnopqrstuvwxyz</pre> |
||
Old style Property and enumerable based solution |
Old style Property and enumerable based solution |
||
< |
<syntaxhighlight lang="csharp">namespace RosettaCode.GenerateLowerCaseASCIIAlphabet |
||
{ |
{ |
||
using System; |
using System; |
||
Line 722: | Line 771: | ||
} |
} |
||
} |
} |
||
}</ |
}</syntaxhighlight>{{Output}}<pre>abcdefghijklmnopqrstuvwxyz</pre> |
||
=={{header|C++}}== |
=={{header|C++}}== |
||
C++ can do the task in the identical way as C, or else, it can use a STL function. |
C++ can do the task in the identical way as C, or else, it can use a STL function. |
||
{{works with|C++11}} |
{{works with|C++11}} |
||
< |
<syntaxhighlight lang="cpp">#include <string> |
||
#include <numeric> |
#include <numeric> |
||
Line 734: | Line 783: | ||
std::iota(lower.begin(), lower.end(), 'a'); |
std::iota(lower.begin(), lower.end(), 'a'); |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Clojure}}== |
=={{header|Clojure}}== |
||
< |
<syntaxhighlight lang="clojure">(map char (range (int \a) (inc (int \z))))</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 743: | Line 792: | ||
</pre> |
</pre> |
||
=={{header|CLU}}== |
|||
<syntaxhighlight lang="clu">alph = proc () returns (string) |
|||
a: int := char$c2i('a') |
|||
letters: array[char] := array[char]$predict(1,26) |
|||
for i: int in int$from_to(0, 25) do |
|||
array[char]$addh(letters, char$i2c(a + i)) |
|||
end |
|||
return(string$ac2s(letters)) |
|||
end alph |
|||
% test |
|||
start_up = proc () |
|||
stream$putl(stream$primary_output(), alph()) |
|||
end start_up</syntaxhighlight> |
|||
{{out}} |
|||
<pre>abcdefghijklmnopqrstuvwxyz</pre> |
|||
=={{header|COBOL}}== |
=={{header|COBOL}}== |
||
Strings in COBOL are mutable and can be subscripted: each time we go round the loop, we assign to a one-character-long section of the string we are building. |
Strings in COBOL are mutable and can be subscripted: each time we go round the loop, we assign to a one-character-long section of the string we are building. |
||
< |
<syntaxhighlight lang="cobol">identification division. |
||
program-id. lower-case-alphabet-program. |
program-id. lower-case-alphabet-program. |
||
data division. |
data division. |
||
Line 761: | Line 826: | ||
add-next-letter-paragraph. |
add-next-letter-paragraph. |
||
add 97 to loop-counter giving character-code. |
add 97 to loop-counter giving character-code. |
||
move function char(character-code) to lower-case-alphabet(loop-counter:1).</ |
move function char(character-code) to lower-case-alphabet(loop-counter:1).</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>abcdefghijklmnopqrstuvwxyz</pre> |
<pre>abcdefghijklmnopqrstuvwxyz</pre> |
||
=={{header|CoffeeScript}}== |
=={{header|CoffeeScript}}== |
||
< |
<syntaxhighlight lang="coffeescript"> |
||
(String.fromCharCode(x) for x in [97..122]) |
(String.fromCharCode(x) for x in [97..122]) |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Comal}}== |
=={{header|Comal}}== |
||
< |
<syntaxhighlight lang="comal">dim alphabet$ of 26 |
||
for i := 1 to 26 |
for i := 1 to 26 |
||
alphabet$(i) := chr$(ord("a") - 1 + i) |
alphabet$(i) := chr$(ord("a") - 1 + i) |
||
endfor i |
endfor i |
||
print alphabet$</ |
print alphabet$</syntaxhighlight> |
||
{{Out}} |
{{Out}} |
||
<pre>abcdefghijklmnopqrstuvwxyz</pre> |
<pre>abcdefghijklmnopqrstuvwxyz</pre> |
||
Line 781: | Line 846: | ||
=={{header|Common Lisp}}== |
=={{header|Common Lisp}}== |
||
<nowiki>;; as a list</nowiki> |
<nowiki>;; as a list</nowiki> |
||
< |
<syntaxhighlight lang="lisp">(defvar *lower* |
||
(loop with a = (char-code #\a) |
(loop with a = (char-code #\a) |
||
for i below 26 |
for i below 26 |
||
collect (code-char (+ a i))))</ |
collect (code-char (+ a i))))</syntaxhighlight> |
||
<nowiki>;; as a string</nowiki> |
<nowiki>;; as a string</nowiki> |
||
< |
<syntaxhighlight lang="lisp">(defvar *lowercase-alphabet-string* |
||
(map 'string #'code-char (loop |
(map 'string #'code-char (loop |
||
for c from (char-code #\a) to (char-code #\z) |
for c from (char-code #\a) to (char-code #\z) |
||
collect c)) |
collect c)) |
||
"The 26 lower case letters in alphabetical order.")</ |
"The 26 lower case letters in alphabetical order.")</syntaxhighlight> |
||
<nowiki>;; verify</nowiki> |
<nowiki>;; verify</nowiki> |
||
< |
<syntaxhighlight lang="lisp">(assert (= 26 (length *lowercase-alphabet-string*) (length *lower*))) |
||
(assert (every #'char< *lowercase-alphabet-string* (subseq *lowercase-alphabet-string* 1))) |
(assert (every #'char< *lowercase-alphabet-string* (subseq *lowercase-alphabet-string* 1))) |
||
(assert (apply #'char< *lower*)) |
(assert (apply #'char< *lower*)) |
||
(assert (string= *lowercase-alphabet-string* (coerce *lower* 'string)))</ |
(assert (string= *lowercase-alphabet-string* (coerce *lower* 'string)))</syntaxhighlight> |
||
=={{header|Cowgol}}== |
=={{header|Cowgol}}== |
||
< |
<syntaxhighlight lang="cowgol">include "cowgol.coh"; |
||
# Generate the alphabet and store it at the given location |
# Generate the alphabet and store it at the given location |
||
Line 817: | Line 882: | ||
# Use the subroutine to print the alphabet |
# Use the subroutine to print the alphabet |
||
var buf: uint8[27]; # make room for the alphabet |
var buf: uint8[27]; # make room for the alphabet |
||
print(alph(&buf as [uint8]));</ |
print(alph(&buf as [uint8]));</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 825: | Line 890: | ||
=={{header|D}}== |
=={{header|D}}== |
||
The lower case ASCII letters of the Phobos standard library: |
The lower case ASCII letters of the Phobos standard library: |
||
< |
<syntaxhighlight lang="d">import std.ascii: lowercase; |
||
void main() {}</ |
void main() {}</syntaxhighlight> |
||
The generation of the ASCII alphabet array: |
The generation of the ASCII alphabet array: |
||
< |
<syntaxhighlight lang="d">void main() { |
||
char['z' - 'a' + 1] arr; |
char['z' - 'a' + 1] arr; |
||
foreach (immutable i, ref c; arr) |
foreach (immutable i, ref c; arr) |
||
c = 'a' + i; |
c = 'a' + i; |
||
}</ |
}</syntaxhighlight> |
||
An alternative version: |
An alternative version: |
||
< |
<syntaxhighlight lang="d">void main() { |
||
import std.range, std.algorithm, std.array; |
import std.range, std.algorithm, std.array; |
||
char[26] arr = 26.iota.map!(i => cast(char)('a' + i)).array; |
char[26] arr = 26.iota.map!(i => cast(char)('a' + i)).array; |
||
}</ |
}</syntaxhighlight> |
||
Another version: |
Another version: |
||
< |
<syntaxhighlight lang="d">void main() { |
||
char[] arr; |
char[] arr; |
||
Line 851: | Line 916: | ||
assert(arr == "abcdefghijklmnopqrstuvwxyz"); |
assert(arr == "abcdefghijklmnopqrstuvwxyz"); |
||
}</ |
}</syntaxhighlight> |
||
=={{header|dc}}== |
=={{header|dc}}== |
||
Construct the numerical representation of the desired output and print it. |
Construct the numerical representation of the desired output and print it. |
||
< |
<syntaxhighlight lang="dc">122 [ d 1 - d 97<L 256 * + ] d sL x P</syntaxhighlight> |
||
Output: |
Output: |
||
<pre> |
<pre> |
||
Line 862: | Line 927: | ||
=={{header|Delphi}}== |
=={{header|Delphi}}== |
||
< |
<syntaxhighlight lang="delphi">program atoz; |
||
var |
var |
||
Line 872: | Line 937: | ||
write(ch); |
write(ch); |
||
end; |
end; |
||
end.</ |
end.</syntaxhighlight>{{Output}}<pre>abcdefghijklmnopqrstuvwxyz</pre> |
||
=={{header|Draco}}== |
|||
<syntaxhighlight lang="draco">/* Generate the lowercase alphabet and store it in a buffer */ |
|||
proc alph(*char buf) *char: |
|||
channel output text ch; |
|||
char letter; |
|||
open(ch, buf); |
|||
for letter from 'a' upto 'z' do |
|||
write(ch; letter) |
|||
od; |
|||
close(ch); |
|||
buf |
|||
corp |
|||
/* Use the function to print the alphabet */ |
|||
proc main() void: |
|||
[27] char buf; /* one byte extra for the string terminator */ |
|||
writeln(alph(&buf[0])) |
|||
corp</syntaxhighlight> |
|||
{{out}} |
|||
<pre>abcdefghijklmnopqrstuvwxyz</pre> |
|||
=={{header|DUP}}== |
=={{header|DUP}}== |
||
Line 878: | Line 964: | ||
In DUP, strings between double quotes are stored in a numerically addressed array. The integer before the first <code>"</code> which gets pushed on the data stack, defines the cell address in which the ASCII value of first character of the string will be stored. All following characters will be stored like an array as values in the following cells. At the end, DUP pushes the length of the string on the data stack. |
In DUP, strings between double quotes are stored in a numerically addressed array. The integer before the first <code>"</code> which gets pushed on the data stack, defines the cell address in which the ASCII value of first character of the string will be stored. All following characters will be stored like an array as values in the following cells. At the end, DUP pushes the length of the string on the data stack. |
||
< |
<syntaxhighlight lang="dup">0"abcdefghijklmnopqrstuvwxyz" {store character values of string in cells 0..length of string-1} |
||
26[$][^^-;,1-]# {Loop from 26-26 to 26-0, print the respective cell contents to STDOUT}</ |
26[$][^^-;,1-]# {Loop from 26-26 to 26-0, print the respective cell contents to STDOUT}</syntaxhighlight> |
||
Output: |
Output: |
||
Line 889: | Line 975: | ||
Generates a lazy sequence and prints it to a standard output: |
Generates a lazy sequence and prints it to a standard output: |
||
< |
<syntaxhighlight lang="dyalect">print << ('a'..'z').ToArray()</syntaxhighlight> |
||
=={{header|EasyLang}}== |
|||
<syntaxhighlight lang="easylang"> |
|||
# Generated on an array |
|||
for i = 97 to 122 |
|||
alphabet$[] &= strchar i |
|||
. |
|||
print alphabet$[] |
|||
# Generated on a string |
|||
for i = 97 to 122 |
|||
alphabet$ &= strchar i |
|||
. |
|||
print alphabet$ |
|||
</syntaxhighlight> |
|||
=={{header|EchoLisp}}== |
=={{header|EchoLisp}}== |
||
< |
<syntaxhighlight lang="scheme"> |
||
;; 1) |
;; 1) |
||
(define \a (first (string->unicode "a"))) |
(define \a (first (string->unicode "a"))) |
||
Line 907: | Line 1,007: | ||
(for/string ((letter ["a" .. "z"])) letter) |
(for/string ((letter ["a" .. "z"])) letter) |
||
→ abcdefghijklmnopqrstuvwxyz |
→ abcdefghijklmnopqrstuvwxyz |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Elena}}== |
=={{header|Elena}}== |
||
ELENA |
ELENA 6.x : |
||
< |
<syntaxhighlight lang="elena">import extensions; |
||
import system'collections; |
import system'collections; |
||
Line 920: | Line 1,020: | ||
char current; |
char current; |
||
get() = current; |
get Value() = current; |
||
bool next() |
bool next() |
||
Line 952: | Line 1,052: | ||
{ |
{ |
||
console.printLine(Alphabet) |
console.printLine(Alphabet) |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 959: | Line 1,059: | ||
=={{header|Elixir}}== |
=={{header|Elixir}}== |
||
< |
<syntaxhighlight lang="elixir">iex(1)> Enum.to_list(?a .. ?z) |
||
'abcdefghijklmnopqrstuvwxyz' |
'abcdefghijklmnopqrstuvwxyz' |
||
iex(2)> Enum.to_list(?a .. ?z) |> List.to_string |
iex(2)> Enum.to_list(?a .. ?z) |> List.to_string |
||
"abcdefghijklmnopqrstuvwxyz"</ |
"abcdefghijklmnopqrstuvwxyz"</syntaxhighlight> |
||
=={{header|Erlang}}== |
=={{header|Erlang}}== |
||
< |
<syntaxhighlight lang="erlang">lists:seq($a,$z).</syntaxhighlight> |
||
{{Output}} |
{{Output}} |
||
Line 978: | Line 1,078: | ||
{{Works with|Office 365 betas 2021}} |
{{Works with|Office 365 betas 2021}} |
||
< |
<syntaxhighlight lang="lisp">showAlphabet |
||
=LAMBDA(az, |
=LAMBDA(az, |
||
ENUMFROMTOCHAR( |
ENUMFROMTOCHAR( |
||
Line 985: | Line 1,085: | ||
MID(az, 2, 1) |
MID(az, 2, 1) |
||
) |
) |
||
)</ |
)</syntaxhighlight> |
||
and also assuming the following generic binding in the Name Manager for the WorkBook: |
and also assuming the following generic binding in the Name Manager for the WorkBook: |
||
< |
<syntaxhighlight lang="lisp">ENUMFROMTOCHAR |
||
=LAMBDA(a, |
=LAMBDA(a, |
||
LAMBDA(z, |
LAMBDA(z, |
||
Line 1,010: | Line 1,110: | ||
) |
) |
||
) |
) |
||
)</ |
)</syntaxhighlight> |
||
{{Out}} |
{{Out}} |
||
Line 1,261: | Line 1,361: | ||
=={{header|F_Sharp|F#}}== |
=={{header|F_Sharp|F#}}== |
||
< |
<syntaxhighlight lang="fsharp">let lower = ['a'..'z'] |
||
printfn "%A" lower</ |
printfn "%A" lower</syntaxhighlight> |
||
=={{header|Factor}}== |
=={{header|Factor}}== |
||
Strings are represented as fixed-size mutable sequences of Unicode code points. |
Strings are represented as fixed-size mutable sequences of Unicode code points. |
||
< |
<syntaxhighlight lang="factor">USING: spelling ; ! ALPHABET |
||
ALPHABET print |
ALPHABET print |
||
Line 1,274: | Line 1,374: | ||
: russian-alphabet-without-io ( -- str ) 0x0430 0x0450 [a,b) >string ; |
: russian-alphabet-without-io ( -- str ) 0x0430 0x0450 [a,b) >string ; |
||
: russian-alphabet ( -- str ) 0x0451 6 russian-alphabet-without-io insert-nth ; |
: russian-alphabet ( -- str ) 0x0451 6 russian-alphabet-without-io insert-nth ; |
||
russian-alphabet print</ |
russian-alphabet print</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>abcdefghijklmnopqrstuvwxyz |
<pre>abcdefghijklmnopqrstuvwxyz |
||
Line 1,281: | Line 1,381: | ||
=={{header|FALSE}}== |
=={{header|FALSE}}== |
||
< |
<syntaxhighlight lang="false">'a[$'z>~][$,1+]#%</syntaxhighlight> |
||
{{Out}} |
{{Out}} |
||
Line 1,287: | Line 1,387: | ||
=={{header|Fermat}}== |
=={{header|Fermat}}== |
||
< |
<syntaxhighlight lang="fermat">Array locase[1,26]; |
||
[locase]:=[<i=1,26>'a'+i-1]; |
[locase]:=[<i=1,26>'a'+i-1]; |
||
!([locase:char);</ |
!([locase:char);</syntaxhighlight> |
||
{{out}}<pre>abcdefghijklmnopqrstuvwxyz</pre> |
{{out}}<pre>abcdefghijklmnopqrstuvwxyz</pre> |
||
=={{header|Forth}}== |
=={{header|Forth}}== |
||
Generate a string filled with the lowercase ASCII alphabet |
Generate a string filled with the lowercase ASCII alphabet |
||
< |
<syntaxhighlight lang="forth">: printit 26 0 do [char] a I + emit loop ;</syntaxhighlight> |
||
Or coded another way |
Or coded another way |
||
< |
<syntaxhighlight lang="forth">: printit2 [char] z 1+ [char] a do I emit loop ;</syntaxhighlight> |
||
We could do something more complicated and allocate space for a string and fill it. |
We could do something more complicated and allocate space for a string and fill it. |
||
Two methods are demonstrated below |
Two methods are demonstrated below |
||
<lang>create lalpha 27 chars allot \ create a string in memory for 26 letters and count byte |
<syntaxhighlight lang="forth">create lalpha 27 chars allot \ create a string in memory for 26 letters and count byte |
||
: ]lalpha ( index -- addr ) |
: ]lalpha ( index -- addr ) \ index the string like an array (return an address) |
||
lalpha char+ + ; |
lalpha char+ + ; |
||
Line 1,319: | Line 1,419: | ||
: Loadit s" abcdefghijklmnopqrstuvwxyz" lalpha PLACE ; |
: Loadit s" abcdefghijklmnopqrstuvwxyz" lalpha PLACE ; |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{Output}}Test at the console |
{{Output}}Test at the console |
||
<lang>printit abcdefghijklmnopqrstuvwxyz ok |
<syntaxhighlight lang="text">printit abcdefghijklmnopqrstuvwxyz ok |
||
fillit ok |
fillit ok |
||
Line 1,330: | Line 1,430: | ||
loadit ok |
loadit ok |
||
lalpha count type abcdefghijklmnopqrstuvwxyz ok |
lalpha count type abcdefghijklmnopqrstuvwxyz ok |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Fortran}}== |
=={{header|Fortran}}== |
||
{{works with|Fortran|90 and later}} |
{{works with|Fortran|90 and later}} |
||
< |
<syntaxhighlight lang="fortran"> character(26) :: alpha |
||
integer :: i |
integer :: i |
||
do i = 1, 26 |
do i = 1, 26 |
||
alpha(i:i) = achar(iachar('a') + i - 1) |
alpha(i:i) = achar(iachar('a') + i - 1) |
||
end do</ |
end do</syntaxhighlight> |
||
=={{header|Free Pascal}}== |
=={{header|Free Pascal}}== |
||
One can use ''set constructors'' like in [[#Delphi|Delphi]]. |
One can use ''set constructors'' like in [[#Delphi|Delphi]]. |
||
<tt>alphabet</tt>’s type will be <tt>set of char</tt>. |
<tt>alphabet</tt>’s type will be <tt>set of char</tt>. |
||
< |
<syntaxhighlight lang="pascal">program lowerCaseAscii(input, output, stdErr); |
||
const |
const |
||
alphabet = ['a'..'z']; |
alphabet = ['a'..'z']; |
||
begin |
begin |
||
end.</ |
end.</syntaxhighlight> |
||
Note, Pascal does not define that the letters A through Z are contiguous, the set constructor above assumes that, though. |
Note, Pascal does not define that the letters A through Z are contiguous, the set constructor above assumes that, though. |
||
However, the FPC – the FreePascal compiler – virtually only works on systems, that use at least ASCII as common denominator. |
However, the FPC – the FreePascal compiler – virtually only works on systems, that use at least ASCII as common denominator. |
||
Line 1,354: | Line 1,454: | ||
=={{header|Frink}}== |
=={{header|Frink}}== |
||
The following produces a lazy enumerating sequence of the characters. |
The following produces a lazy enumerating sequence of the characters. |
||
< |
<syntaxhighlight lang="frink">map["char", char["a"] to char["z"]]</syntaxhighlight> |
||
To produce a non-lazy array of the characters, you can wrap the above in a <CODE>toArray</CODE> call: |
To produce a non-lazy array of the characters, you can wrap the above in a <CODE>toArray</CODE> call: |
||
< |
<syntaxhighlight lang="frink">toArray[map["char", char["a"] to char["z"]]]</syntaxhighlight> |
||
=={{header|Furor}}== |
=={{header|Furor}}== |
||
<syntaxhighlight lang="furor"> |
|||
<lang Furor> |
|||
#k 'a 'z ++ {|| {} print SPACE |} NL end |
#k 'a 'z ++ {|| {} print SPACE |} NL end |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{out}} |
{{out}} |
||
<pre> |
<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> |
</pre> |
||
=={{header|Peri}}== |
|||
<syntaxhighlight lang="peri"> |
|||
###sysinclude standard.uh |
|||
#k 'a 'z ++ {{ , {{}} print SPACE }} NL end |
|||
</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 |
|||
</pre> |
|||
=={{header|FutureBasic}}== |
|||
<syntaxhighlight lang="futurebasic"> |
|||
long i |
|||
for i = asc("a") to asc("z") |
|||
print chr$(i); |
|||
next |
|||
HandleEvents |
|||
</syntaxhighlight> |
|||
{{output}} |
|||
<pre> |
|||
abcdefghijklmnopqrstuvwxyz |
|||
</pre> |
|||
=={{header|Gambas}}== |
=={{header|Gambas}}== |
||
'''[https://gambas-playground.proko.eu/?gist=debd3987d4db75099032a86927978046 Click this link to run this code]''' |
'''[https://gambas-playground.proko.eu/?gist=debd3987d4db75099032a86927978046 Click this link to run this code]''' |
||
< |
<syntaxhighlight lang="gambas">Public Sub Main() |
||
Dim siCount As Short |
Dim siCount As Short |
||
Line 1,376: | Line 1,500: | ||
Next |
Next |
||
End</ |
End</syntaxhighlight> |
||
Output: |
Output: |
||
<pre> |
<pre> |
||
Line 1,383: | Line 1,507: | ||
=={{header|Go}}== |
=={{header|Go}}== |
||
< |
<syntaxhighlight lang="go">func loweralpha() string { |
||
p := make([]byte, 26) |
p := make([]byte, 26) |
||
for i := range p { |
for i := range p { |
||
Line 1,389: | Line 1,513: | ||
} |
} |
||
return string(p) |
return string(p) |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Groovy}}== |
=={{header|Groovy}}== |
||
< |
<syntaxhighlight lang="groovy">def lower = ('a'..'z')</syntaxhighlight> |
||
Test |
Test |
||
< |
<syntaxhighlight lang="groovy">assert 'abcdefghijklmnopqrstuvwxyz' == lower.join('')</syntaxhighlight> |
||
=={{header|Haskell}}== |
=={{header|Haskell}}== |
||
< |
<syntaxhighlight lang="haskell">lower = ['a' .. 'z'] |
||
main = print lower</ |
main = print lower</syntaxhighlight> |
||
Or, equivalently: |
Or, equivalently: |
||
< |
<syntaxhighlight lang="haskell">alpha :: String |
||
alpha = enumFromTo 'a' 'z' |
alpha = enumFromTo 'a' 'z' |
||
main :: IO () |
main :: IO () |
||
main = print alpha</ |
main = print alpha</syntaxhighlight> |
||
{{Out}} |
{{Out}} |
||
<pre>"abcdefghijklmnopqrstuvwxyz"</pre> |
<pre>"abcdefghijklmnopqrstuvwxyz"</pre> |
||
=={{header|Hoon}}== |
|||
<syntaxhighlight lang="hoon">`(list cord)`(gulf 97 122)</syntaxhighlight> |
|||
{{Out}} |
|||
<pre> |
|||
> `(list cord)`(gulf 97 122) |
|||
<|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|Huginn}}== |
=={{header|Huginn}}== |
||
< |
<syntaxhighlight lang="huginn">import Algorithms as algo; |
||
import Text as text; |
import Text as text; |
||
Line 1,432: | Line 1,564: | ||
) |
) |
||
); |
); |
||
}</ |
}</syntaxhighlight> |
||
{{Out}} |
{{Out}} |
||
<pre>abcdefghijklmnopqrstuvwxyz |
<pre>abcdefghijklmnopqrstuvwxyz |
||
Line 1,444: | Line 1,576: | ||
E.g. |
E.g. |
||
< |
<syntaxhighlight lang="unicon">every a := put([], !&lcase) # array of 1 character per element |
||
c := create !&lcase # lazy generation of letters in sequence</ |
c := create !&lcase # lazy generation of letters in sequence</syntaxhighlight> |
||
< |
<syntaxhighlight lang="icon"> |
||
procedure lower_case_letters() # entry point for function lower_case_letters |
procedure lower_case_letters() # entry point for function lower_case_letters |
||
return &lcase # returning lower caser letters represented by the set &lcase |
return &lcase # returning lower caser letters represented by the set &lcase |
||
Line 1,455: | Line 1,587: | ||
write(lower_case_letters()) # output of result of function lower_case_letters() |
write(lower_case_letters()) # output of result of function lower_case_letters() |
||
end |
end |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Insitux}}== |
|||
<syntaxhighlight lang="insitux>(-> (map char-code "az") |
|||
(adj _ inc) |
|||
(.. range) |
|||
(map char-code))</syntaxhighlight> |
|||
<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"] |
|||
</pre> |
|||
=={{header|J}}== |
=={{header|J}}== |
||
'''Solution''':< |
'''Solution''':<syntaxhighlight lang="j"> thru=: <. + i.@(+*)@-~ |
||
thru&.(a.&i.)/'az' |
thru&.(a.&i.)/'az' |
||
abcdefghijklmnopqrstuvwxyz</ |
abcdefghijklmnopqrstuvwxyz</syntaxhighlight> |
||
or< |
or<syntaxhighlight lang="j"> u:97+i.26 |
||
abcdefghijklmnopqrstuvwxyz</ |
abcdefghijklmnopqrstuvwxyz</syntaxhighlight> |
||
or<syntaxhighlight lang="j"> ([-.toupper)a. |
|||
abcdefghijklmnopqrstuvwxyz</syntaxhighlight> |
|||
and, obviously, other variations are possible. |
and, obviously, other variations are possible. |
||
=={{header|Java}}== |
=={{header|Java}}== |
||
<syntaxhighlight lang="java"> |
|||
<lang java>public class LowerAscii { |
|||
char[] lowerAlphabet() { |
|||
char[] letters = new char[26]; |
|||
for (int code = 97; code < 123; code++) |
|||
letters[code - 97] = (char) code; |
|||
return letters; |
|||
} |
|||
</syntaxhighlight> |
|||
<pre> |
|||
abcdefghijklmnopqrstuvwxyz |
|||
</pre> |
|||
An alternate implementation |
|||
<syntaxhighlight lang="java">public class LowerAscii { |
|||
public static void main(String[] args) { |
public static void main(String[] args) { |
||
Line 1,474: | Line 1,630: | ||
System.out.printf("lower ascii: %s, length: %s", sb, sb.length()); |
System.out.printf("lower ascii: %s, length: %s", sb, sb.length()); |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
Output: |
Output: |
||
Line 1,488: | Line 1,644: | ||
For Unicode characters beyond this range, in ES5 we have to enter a pair of Unicode number escapes. |
For Unicode characters beyond this range, in ES5 we have to enter a pair of Unicode number escapes. |
||
< |
<syntaxhighlight lang="javascript">(function (cFrom, cTo) { |
||
function cRange(cFrom, cTo) { |
function cRange(cFrom, cTo) { |
||
Line 1,504: | Line 1,660: | ||
return cRange(cFrom, cTo); |
return cRange(cFrom, cTo); |
||
})('a', 'z');</ |
})('a', 'z');</syntaxhighlight> |
||
Returns: |
Returns: |
||
< |
<syntaxhighlight lang="javascript">["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"]</syntaxhighlight> |
||
===ES6=== |
===ES6=== |
||
Line 1,513: | Line 1,669: | ||
In ES6, the new '''String.fromCodePoint()''' method can can return 4-byte characters (such as Emoji, for example) as well as the usual 2-byte characters. |
In ES6, the new '''String.fromCodePoint()''' method can can return 4-byte characters (such as Emoji, for example) as well as the usual 2-byte characters. |
||
< |
<syntaxhighlight lang="javascript">(function (lstRanges) { |
||
function cRange(cFrom, cTo) { |
function cRange(cFrom, cTo) { |
||
Line 1,534: | Line 1,690: | ||
['a', 'z'], |
['a', 'z'], |
||
['🐐', '🐟'] |
['🐐', '🐟'] |
||
]);</ |
]);</syntaxhighlight> |
||
Output: |
Output: |
||
< |
<syntaxhighlight lang="javascript">[["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"], |
||
["🐐", "🐑", "🐒", "🐓", "🐔", "🐕", "🐖", "🐗", "🐘", "🐙", "🐚", "🐛", "🐜", "🐝", "🐞", "🐟"]]</ |
["🐐", "🐑", "🐒", "🐓", "🐔", "🐕", "🐖", "🐗", "🐘", "🐙", "🐚", "🐛", "🐜", "🐝", "🐞", "🐟"]]</syntaxhighlight> |
||
{{works with|ECMAScript|6}} |
{{works with|ECMAScript|6}} |
||
< |
<syntaxhighlight lang="javascript">var letters = [] |
||
for (var i = 97; i <= 122; i++) { |
for (var i = 97; i <= 122; i++) { |
||
letters.push(String.fromCodePoint(i)) |
letters.push(String.fromCodePoint(i)) |
||
}</ |
}</syntaxhighlight> |
||
Or, if we want to write a more general ES6 function: |
Or, if we want to write a more general ES6 function: |
||
< |
<syntaxhighlight lang="javascript">(() => { |
||
// enumFromTo :: Enum a => a -> a -> [a] |
// enumFromTo :: Enum a => a -> a -> [a] |
||
const enumFromTo = (m, n) => { |
const enumFromTo = (m, n) => { |
||
Line 1,603: | Line 1,759: | ||
['🐐', '🐟'] |
['🐐', '🐟'] |
||
])); |
])); |
||
})();</ |
})();</syntaxhighlight> |
||
{{Out}} |
{{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 |
<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 |
||
Line 1,609: | Line 1,765: | ||
א ב ג ד ה ו ז ח ט י ך כ ל ם מ ן נ ס ע ף פ ץ צ ק ר ש ת |
א ב ג ד ה ו ז ח ט י ך כ ל ם מ ן נ ס ע ף פ ץ צ ק ר ש ת |
||
🐐 🐑 🐒 🐓 🐔 🐕 🐖 🐗 🐘 🐙 🐚 🐛 🐜 🐝 🐞 🐟</pre> |
🐐 🐑 🐒 🐓 🐔 🐕 🐖 🐗 🐘 🐙 🐚 🐛 🐜 🐝 🐞 🐟</pre> |
||
=={{header|Joy}}== |
|||
<syntaxhighlight lang="joy">'a ['z =] ["" cons] [dup succ] [cons] linrec.</syntaxhighlight> |
|||
=={{header|jq}}== |
=={{header|jq}}== |
||
< |
<syntaxhighlight lang="jq">"az" | explode | [range( .[0]; 1+.[1] )] | implode'</syntaxhighlight> |
||
produces: |
produces: |
||
Line 1,617: | Line 1,776: | ||
=={{header|Jsish}}== |
=={{header|Jsish}}== |
||
< |
<syntaxhighlight lang="javascript">/* Generate the lower case alphabet with Jsish, assume ASCII */ |
||
var letterA = "a".charCodeAt(0); |
var letterA = "a".charCodeAt(0); |
||
var lowers = Array(26); |
var lowers = Array(26); |
||
Line 1,633: | Line 1,792: | ||
26 |
26 |
||
=!EXPECTEND!= |
=!EXPECTEND!= |
||
*/</ |
*/</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 1,646: | Line 1,805: | ||
{{works with|Julia|0.6}} |
{{works with|Julia|0.6}} |
||
< |
<syntaxhighlight lang="julia">@show collect('a':'z') |
||
@show join('a':'z')</ |
@show join('a':'z')</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 1,655: | Line 1,814: | ||
=={{header|K}}== |
=={{header|K}}== |
||
<tt>`c$</tt> casts a list of integers to a string of characters; <tt>!26</tt> produces a list of the integers from 0 to 25. So the lower-case ASCII alphabet can be generated using: |
<tt>`c$</tt> casts a list of integers to a string of characters; <tt>!26</tt> produces a list of the integers from 0 to 25. So the lower-case ASCII alphabet can be generated using: |
||
<lang |
<syntaxhighlight lang="k">`c$97+!26</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>"abcdefghijklmnopqrstuvwxyz"</pre> |
<pre>"abcdefghijklmnopqrstuvwxyz"</pre> |
||
=={{header|Keg}}== |
=={{header|Keg}}== |
||
<lang |
<syntaxhighlight lang="keg">a(55*|:1+)</syntaxhighlight> |
||
=={{header|Kotlin}}== |
=={{header|Kotlin}}== |
||
< |
<syntaxhighlight lang="scala">// version 1.3.72 |
||
fun main() { |
fun main() { |
||
Line 1,669: | Line 1,828: | ||
println(alphabet) |
println(alphabet) |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 1,677: | Line 1,836: | ||
=={{header|Lambdatalk}}== |
=={{header|Lambdatalk}}== |
||
< |
<syntaxhighlight lang="scheme"> |
||
1) We define code2char & char2code as primitives: |
1) We define code2char & char2code as primitives: |
||
Line 1,700: | Line 1,859: | ||
{S.map code2char {S.serie {char2code 0} {char2code 9}}} |
{S.map code2char {S.serie {char2code 0} {char2code 9}}} |
||
-> 0 1 2 3 4 5 6 7 8 9 |
-> 0 1 2 3 4 5 6 7 8 9 |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Lang}}== |
|||
<syntaxhighlight lang="lang"> |
|||
&alphabet = fn.arrayGenerateFrom(fn.combBX(fn.char, fn.add, a), 26) |
|||
fn.println(&alphabet) |
|||
# As string (Strings are called text in Lang) |
|||
$alphabetText = fn.join(\e, &alphabet) |
|||
fn.println($alphabetText) |
|||
</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] |
|||
abcdefghijklmnopqrstuvwxyz |
|||
</pre> |
|||
=={{header|LC3 Assembly}}== |
=={{header|LC3 Assembly}}== |
||
< |
<syntaxhighlight lang="lc3asm"> .ORIG 0x3000 |
||
LD R0,ASCIIa |
LD R0,ASCIIa |
||
Line 1,717: | Line 1,892: | ||
ASCIIa .FILL 0x61 |
ASCIIa .FILL 0x61 |
||
ASCIIz .FILL 0x7A</ |
ASCIIz .FILL 0x7A</syntaxhighlight> |
||
Output: |
Output: |
||
<pre>abcdefghijklmnopqrstuvwxyz</pre> |
<pre>abcdefghijklmnopqrstuvwxyz</pre> |
||
=={{header|Lingo}}== |
=={{header|Lingo}}== |
||
< |
<syntaxhighlight lang="lingo">alphabet = [] |
||
repeat with i = 97 to 122 |
repeat with i = 97 to 122 |
||
alphabet.add(numtochar(i)) |
alphabet.add(numtochar(i)) |
||
end repeat |
end repeat |
||
put alphabet |
put alphabet |
||
-- ["a", "b", "c", ... , "x", "y", "z"]</ |
-- ["a", "b", "c", ... , "x", "y", "z"]</syntaxhighlight> |
||
=={{header|Logo}}== |
=={{header|Logo}}== |
||
Straightforward, assuming ASCII: |
Straightforward, assuming ASCII: |
||
< |
<syntaxhighlight lang="logo">show map "char iseq 97 122</syntaxhighlight> |
||
Slightly less straightforward, but without the magic numbers: |
Slightly less straightforward, but without the magic numbers: |
||
< |
<syntaxhighlight lang="logo">show map "char apply "iseq map "ascii [a z]</syntaxhighlight> |
||
Same output either way: |
Same output either way: |
||
{{Out}} |
{{Out}} |
||
Line 1,740: | Line 1,915: | ||
=={{header|Lua}}== |
=={{header|Lua}}== |
||
===to table=== |
===to table=== |
||
< |
<syntaxhighlight lang="lua">function getAlphabet () |
||
local letters = {} |
local letters = {} |
||
for ascii = 97, 122 do table.insert(letters, string.char(ascii)) end |
for ascii = 97, 122 do table.insert(letters, string.char(ascii)) end |
||
Line 1,747: | Line 1,922: | ||
local alpha = getAlphabet() |
local alpha = getAlphabet() |
||
print(alpha[25] .. alpha[1] .. alpha[25]) </ |
print(alpha[25] .. alpha[1] .. alpha[25]) </syntaxhighlight> |
||
{{Out}} |
{{Out}} |
||
<pre>yay</pre> |
<pre>yay</pre> |
||
===to string=== |
===to string=== |
||
< |
<syntaxhighlight lang="lua">#!/usr/bin/env luajit |
||
local function ascii(f,t) local tab={} for i=f,t do tab[#tab+1]=string.char(i) end |
local function ascii(f,t) local tab={} for i=f,t do tab[#tab+1]=string.char(i) end |
||
return table.concat(tab) |
return table.concat(tab) |
||
end |
end |
||
print(ascii(97,122))</ |
print(ascii(97,122))</syntaxhighlight> |
||
{{Out}} |
{{Out}} |
||
<pre>> ./lowercaseascii.lua |
<pre>> ./lowercaseascii.lua |
||
Line 1,762: | Line 1,937: | ||
=={{header|M2000 Interpreter}}== |
=={{header|M2000 Interpreter}}== |
||
<syntaxhighlight lang="m2000 interpreter"> |
|||
<lang M2000 Interpreter> |
|||
\\ old style Basic, including a Binary.Or() function |
\\ old style Basic, including a Binary.Or() function |
||
Module OldStyle { |
Module OldStyle { |
||
Line 1,772: | Line 1,947: | ||
} |
} |
||
CALL OldStyle |
CALL OldStyle |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Maple}}== |
=={{header|Maple}}== |
||
< |
<syntaxhighlight lang="maple">seq(StringTools:-Char(c), c = 97 .. 122);</syntaxhighlight> |
||
{{Out}} |
{{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"</pre> |
<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"</pre> |
||
Line 1,792: | Line 1,967: | ||
'''Method 1''': Using a Range Variable. |
'''Method 1''': Using a Range Variable. |
||
<syntaxhighlight lang="mathcad"> |
|||
<lang Mathcad> |
|||
-- user-defined function that returns the ASCII code for string character ch. |
-- user-defined function that returns the ASCII code for string character ch. |
||
code(ch):=str2vec(ch)[0 |
code(ch):=str2vec(ch)[0 |
||
Line 1,813: | Line 1,988: | ||
-- Characters are indexable within the string; for example: substr(lcString,3,1)="d" |
-- Characters are indexable within the string; for example: substr(lcString,3,1)="d" |
||
</ |
</syntaxhighlight> |
||
'''Method 2''': Using a Function. |
'''Method 2''': Using a Function. |
||
<syntaxhighlight lang="mathcad"> |
|||
<lang Mathcad> |
|||
-- Mathcad Express lacks the programming capability of Mathcad Prime, so uses the built-in if function to implement a recursive solution (if(predicate,true expr, false expr)). |
-- Mathcad Express lacks the programming capability of Mathcad Prime, so uses the built-in if function to implement a recursive solution (if(predicate,true expr, false expr)). |
||
Line 1,832: | Line 2,007: | ||
charseq(code("α"),code("ω"))="αβγδεζηθικλμνξοπρςστυφχψω" |
charseq(code("α"),code("ω"))="αβγδεζηθικλμνξοπρςστυφχψω" |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Mathematica}} / {{header|Wolfram Language}}== |
=={{header|Mathematica}} / {{header|Wolfram Language}}== |
||
< |
<syntaxhighlight lang="mathematica">start = 97; |
||
lowerCaseLetters = Table[FromCharacterCode[start + i], {i, 0, 25}]</ |
lowerCaseLetters = Table[FromCharacterCode[start + i], {i, 0, 25}]</syntaxhighlight> |
||
{{Out}} |
{{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"}</pre> |
<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"}</pre> |
||
=={{header|MATLAB}} / {{header|Octave}}== |
=={{header|MATLAB}} / {{header|Octave}}== |
||
<lang |
<syntaxhighlight lang="matlab"> 'a':'z'</syntaxhighlight> |
||
or alternatively |
or alternatively |
||
< |
<syntaxhighlight lang="matlab"> char(96+[1:26])</syntaxhighlight> |
||
{{Out}}<pre> abcdefghijklmnopqrstuvwxyz</pre> |
{{Out}}<pre> abcdefghijklmnopqrstuvwxyz</pre> |
||
=={{header|Maxima}}== |
=={{header|Maxima}}== |
||
<syntaxhighlight lang="maxima"> |
|||
<lang Maxima> |
|||
delete([], makelist(if(alphacharp(ascii(i))) then parse_string(ascii(i)) else [], i, 96, 122));</ |
delete([], makelist(if(alphacharp(ascii(i))) then parse_string(ascii(i)) else [], i, 96, 122));</syntaxhighlight> |
||
{{Out}} |
{{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] </pre> |
<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] </pre> |
||
=={{header|Mercury}}== |
=={{header|Mercury}}== |
||
< |
<syntaxhighlight lang="mercury">:- module gen_lowercase_ascii. |
||
:- interface. |
:- interface. |
||
Line 1,868: | Line 2,043: | ||
io.print_line(Alphabet, !IO). |
io.print_line(Alphabet, !IO). |
||
:- end_module gen_lowercase_ascii.</ |
:- end_module gen_lowercase_ascii.</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 1,875: | Line 2,050: | ||
=={{header|MiniScript}}== |
=={{header|MiniScript}}== |
||
< |
<syntaxhighlight lang="miniscript">letters = [] |
||
for i in range(code("a"), code("z")) |
for i in range(code("a"), code("z")) |
||
letters.push char(i) |
letters.push char(i) |
||
end for |
end for |
||
print letters</ |
print letters</syntaxhighlight> |
||
{{out}} |
{{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"]</pre> |
<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"]</pre> |
||
=={{header|MIPS Assembly}}== |
|||
<syntaxhighlight lang="mips">main: |
|||
li $t0,'a' |
|||
li $t1,26 |
|||
loop: |
|||
jal PrintChar ;prints the low 8 bits of $t0 as an ascii character (unimplemented routine) |
|||
nop ;branch delay slot |
|||
subiu $t1,1 |
|||
bne $t1,loop |
|||
addiu $t0,1 |
|||
end_program: |
|||
j end_program ;halt the cpu - we're done |
|||
nop</syntaxhighlight> |
|||
=={{header|MUMPS}}== |
=={{header|MUMPS}}== |
||
===Caché=== |
|||
{{works with|Caché ObjectScript}} |
{{works with|Caché ObjectScript}} |
||
<syntaxhighlight lang="mumps"> |
|||
<lang MUMPS> |
|||
LOWASCMIN |
LOWASCMIN |
||
set lowstr = "" |
set lowstr = "" |
||
Line 1,893: | Line 2,084: | ||
write lowstr |
write lowstr |
||
quit |
quit |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{out}}<pre> |
{{out}}<pre> |
||
SAMPLES>DO ^LOWASCMIN |
SAMPLES>DO ^LOWASCMIN |
||
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> |
|||
===Standard MUMPS=== |
|||
{{works with|DSM, MSM}} |
|||
<syntaxhighlight lang="mumps"> |
|||
LONG SET D="" |
|||
FOR X=97:1:122 WRITE D,$C(X) SET D="," |
|||
WRITE ! |
|||
QUIT |
|||
; |
|||
SHORT S D="" |
|||
F X=97:1:122 W D,$C(X) S D="," |
|||
W ! |
|||
Q |
|||
</syntaxhighlight> |
|||
{{out}}<pre> |
|||
MGR>DO LONG |
|||
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 |
|||
MGR>D SHORT |
|||
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> |
</pre> |
||
=={{header|Nanoquery}}== |
=={{header|Nanoquery}}== |
||
< |
<syntaxhighlight lang="nanoquery">lowercase = list() |
||
for i in range(ord("a"), ord("z")) |
for i in range(ord("a"), ord("z")) |
||
lowercase.append(chr(i)) |
lowercase.append(chr(i)) |
||
end |
end |
||
println lowercase</ |
println lowercase</syntaxhighlight> |
||
{{out}} |
{{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]</pre> |
<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]</pre> |
||
=={{header|Neko}}== |
=={{header|Neko}}== |
||
<syntaxhighlight lang="actionscript">/** |
|||
<lang ActionScript>/** |
|||
<doc>Generate lower case ASCII, in Neko</doc> |
<doc>Generate lower case ASCII, in Neko</doc> |
||
**/ |
**/ |
||
Line 1,924: | Line 2,136: | ||
} |
} |
||
$print(generated, "\n")</ |
$print(generated, "\n")</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 1,932: | Line 2,144: | ||
=={{header|NESL}}== |
=={{header|NESL}}== |
||
< |
<syntaxhighlight lang="nesl">lower_case_ascii = {code_char(c) : c in [97:123]};</syntaxhighlight> |
||
=={{header|NetLogo}}== |
|||
====Rationale==== |
|||
Since NetLogo has no "ASC" type reporters, we will have to enumerate the characters. |
|||
To make an omission easier to detect, we use a phrase, instead of a list |
|||
Since the phrase has duplicates and spaces, we use other list tools to produce just the sorted alphabet |
|||
====Code==== |
|||
<syntaxhighlight lang="netlogo"> |
|||
to-report alphabet-lower |
|||
let sample "sphinx of black quartz judge my vow" |
|||
let alphabet sort remove-duplicates remove " " n-values length sample [ c -> item c sample ] |
|||
if length alphabet != 26 [ user-message "ERROR: invalid sample for alphabet function" ] |
|||
report alphabet |
|||
end |
|||
</syntaxhighlight> |
|||
====Output==== |
|||
<pre> |
|||
observer> print alphabet-lower |
|||
[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] |
|||
observer> write alphabet-lower |
|||
["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|Nim}}== |
=={{header|Nim}}== |
||
< |
<syntaxhighlight lang="nim"># A slice just contains the first and last value |
||
let alpha: Slice[char] = 'a'..'z' |
let alpha: Slice[char] = 'a'..'z' |
||
echo alpha # (a: a, b: z) |
echo alpha # (a: a, b: z) |
||
Line 1,954: | Line 2,187: | ||
let alphaSeq = toSeq 'a'..'z' |
let alphaSeq = toSeq 'a'..'z' |
||
echo alphaSeq # @[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] |
echo alphaSeq # @[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] |
||
echo alphaSeq[10] # k</ |
echo alphaSeq[10] # k</syntaxhighlight> |
||
=={{header|Nu}}== |
|||
<syntaxhighlight lang="nu">seq char a z</syntaxhighlight> |
|||
=={{header|OCaml}}== |
=={{header|OCaml}}== |
||
< |
<syntaxhighlight lang="ocaml"># Array.make 26 'a' |> Array.mapi (fun i c -> int_of_char c + i |> char_of_int);; |
||
- : char array = |
- : char array = |
||
[|'a'; 'b'; 'c'; 'd'; 'e'; 'f'; 'g'; 'h'; 'i'; 'j'; 'k'; 'l'; 'm'; 'n'; 'o'; |
[|'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'|]</ |
'p'; 'q'; 'r'; 's'; 't'; 'u'; 'v'; 'w'; 'x'; 'y'; 'z'|]</syntaxhighlight> |
||
Alternative version: |
|||
<syntaxhighlight lang="ocaml">Array.init 26 (fun x -> char_of_int (x + int_of_char 'a'))</syntaxhighlight> |
|||
=={{header|Oforth}}== |
=={{header|Oforth}}== |
||
Oforth characters are integers. This list is a list of 26 integers |
Oforth characters are integers. This list is a list of 26 integers |
||
<lang |
<syntaxhighlight lang="oforth">'a' 'z' seqFrom</syntaxhighlight> |
||
If necessary, these integers can be added to a string to have a indexed string of chars |
If necessary, these integers can be added to a string to have a indexed string of chars |
||
< |
<syntaxhighlight lang="oforth">StringBuffer new 'a' 'z' seqFrom apply(#<<c)</syntaxhighlight> |
||
=={{header|PARI/GP}}== |
=={{header|PARI/GP}}== |
||
< |
<syntaxhighlight lang="parigp">Strchr(Vecsmall([97..122]))</syntaxhighlight> |
||
Output:<pre>"abcdefghijklmnopqrstuvwxyz"</pre> |
Output:<pre>"abcdefghijklmnopqrstuvwxyz"</pre> |
||
=={{header|Pascal}}== |
=={{header|Pascal}}== |
||
< |
<syntaxhighlight lang="pascal">program lowerCaseAscii(input, output, stdErr); |
||
var |
var |
||
alphabet: set of char; |
alphabet: set of char; |
||
Line 1,985: | Line 2,224: | ||
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' |
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' |
||
]; |
]; |
||
end.</ |
end.</syntaxhighlight> |
||
=={{header|PascalABC.NET}}== |
|||
<syntaxhighlight lang="delphi"> |
|||
## |
|||
var a := Arr('a'..'z'); |
|||
a.Println; |
|||
var s := ('a'..'z').JoinToString(' ');; |
|||
s.Println |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
abcdefghijklmnopqrstuvwxyz |
|||
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|Perl}}== |
=={{header|Perl}}== |
||
<lang |
<syntaxhighlight lang="perl">print 'a'..'z'</syntaxhighlight> |
||
=={{header|Phix}}== |
=={{header|Phix}}== |
||
<!--< |
<!--<syntaxhighlight lang="phix">(phixonline)--> |
||
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span> |
|||
<span style="color: #004080;">string</span> <span style="color: #000000;">az</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">""</span> |
<span style="color: #004080;">string</span> <span style="color: #000000;">az</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">""</span> |
||
<span style="color: #008080;">for</span> <span style="color: #000000;">ch</span><span style="color: #0000FF;">=</span><span style="color: #008000;">'a'</span> <span style="color: #008080;">to</span> <span style="color: #008000;">'z'</span> <span style="color: #008080;">do</span> |
|||
<span style="color: #000000;">az</span> <span style="color: #0000FF;">&=</span> <span style="color: #000000;">ch</span> |
|||
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span> |
|||
<span style="color: #0000FF;">?</span><span style="color: #000000;">az</span> |
<span style="color: #0000FF;">?</span><span style="color: #000000;">az</span> |
||
<span style="color: #0000FF;">?</span><span style="color: #7060A8;">tagset</span><span style="color: #0000FF;">(</span><span style="color: #008000;">'z'</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'a'</span><span style="color: #0000FF;">)</span> |
<span style="color: #0000FF;">?</span><span style="color: #7060A8;">tagset</span><span style="color: #0000FF;">(</span><span style="color: #008000;">'z'</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'a'</span><span style="color: #0000FF;">)</span> |
||
<span style="color: #0000FF;">?</span><span style="color: #7060A8;">tagstart</span><span style="color: #0000FF;">(</span><span style="color: #008000;">'a'</span><span style="color: #0000FF;">,</span><span style="color: #000000;">26</span><span style="color: #0000FF;">)</span> |
|||
<!--</lang>--> |
|||
<!--</syntaxhighlight>--> |
|||
Using tagset() is obviously easier, but you have to remember its parameters are (finish,start=1,step=1), that way round so that start ''can'' be omitted and default to 1 (ditto step).<br> |
|||
Using tagset() is obviously easier, but you have to remember its parameters are (finish,start=1,step=1), that way round so that start ''can'' be omitted and default to 1 (ditto step). tagstart() wants a length, though you could use 'z'-'a'+1 in place of the 26.<br> |
|||
In Phix there is really not much difference between 1..26 and 'a'..'z', and none ''at all'' between 'a'..'z' and 97..122. |
In Phix there is really not much difference between 1..26 and 'a'..'z', and none ''at all'' between 'a'..'z' and 97..122. |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
"abcdefghijklmnopqrstuvwxyz" |
|||
"abcdefghijklmnopqrstuvwxyz" |
"abcdefghijklmnopqrstuvwxyz" |
||
"abcdefghijklmnopqrstuvwxyz" |
"abcdefghijklmnopqrstuvwxyz" |
||
Line 2,008: | Line 2,264: | ||
=={{header|Phixmonti}}== |
=={{header|Phixmonti}}== |
||
< |
<syntaxhighlight lang="phixmonti">0 tolist |
||
'a' 'z' 2 tolist |
'a' 'z' 2 tolist |
||
for |
for |
||
tochar 0 put |
tochar 0 put |
||
endfor |
endfor |
||
print</ |
print</syntaxhighlight> |
||
Simplest |
Simplest |
||
< |
<syntaxhighlight lang="phixmonti">include ..\Utilitys.pmt |
||
( 'a' 'z' ) for tochar print endfor</ |
( 'a' 'z' ) for tochar print endfor</syntaxhighlight> |
||
=={{header|PHP}}== |
=={{header|PHP}}== |
||
< |
<syntaxhighlight lang="php"><?php |
||
$lower = range('a', 'z'); |
$lower = range('a', 'z'); |
||
var_dump($lower); |
var_dump($lower); |
||
?></ |
?></syntaxhighlight> |
||
=={{header|Picat}}== |
|||
<syntaxhighlight lang="picat">main => |
|||
Alpha1 = (0'a..0'z).map(chr), |
|||
println(Alpha1), |
|||
Alpha2 = [chr(I) : I in 97..122], |
|||
println(Alpha2).</syntaxhighlight> |
|||
{{out}} |
|||
<pre>abcdefghijklmnopqrstuvwxyz |
|||
abcdefghijklmnopqrstuvwxyz</pre> |
|||
=={{header|PicoLisp}}== |
=={{header|PicoLisp}}== |
||
<lang>(mapcar char (range (char "a") (char "z")))</ |
<syntaxhighlight lang="text">(mapcar char (range (char "a") (char "z")))</syntaxhighlight> |
||
=={{header|PL/I}}== |
=={{header|PL/I}}== |
||
< |
<syntaxhighlight lang="pl/i">gen: procedure options (main); /* 7 April 2014. */ |
||
declare 1 ascii union, |
declare 1 ascii union, |
||
2 letters (26) character (1), |
2 letters (26) character (1), |
||
Line 2,042: | Line 2,310: | ||
put edit (letters) (a); |
put edit (letters) (a); |
||
end gen;</ |
end gen;</syntaxhighlight> |
||
Output: |
Output: |
||
<pre> |
<pre> |
||
Line 2,048: | Line 2,316: | ||
</pre> |
</pre> |
||
Alternative, using library: |
Alternative, using library: |
||
<lang> /* Accessing library lower-case ASCII (PC only). */ |
<syntaxhighlight lang="text"> /* Accessing library lower-case ASCII (PC only). */ |
||
letter = lowercase('A'); |
letter = lowercase('A'); |
||
i = index(collate(), letter); |
i = index(collate(), letter); |
||
put skip list (substr(collate, i, 26));</ |
put skip list (substr(collate, i, 26));</syntaxhighlight> |
||
Output: |
Output: |
||
<pre> |
<pre> |
||
Line 2,058: | Line 2,326: | ||
</pre> |
</pre> |
||
=={{header|PL/M}}== |
|||
<syntaxhighlight lang="pli">100H: /* PRINT THE LOWERCASE LETTERS */ |
|||
/* CP/M BDOS SYSTEM CALL */ |
|||
BDOS: PROCEDURE( FN, ARG ); DECLARE FN BYTE, ARG ADDRESS; GOTO 5;END; |
|||
/* CONSOLE OUTPUT ROUTINES */ |
|||
PR$STRING: PROCEDURE( S ); DECLARE S ADDRESS; CALL BDOS( 9, S ); END; |
|||
/* TASK */ |
|||
DECLARE C BYTE, LC ( 27 )BYTE; |
|||
DO C = 0 TO 25; |
|||
LC( C ) = C + 32 + 'A'; |
|||
END; |
|||
LC( LAST( LC ) ) = '$'; /* STRING TERMINATOR */ |
|||
CALL PR$STRING( .LC ); |
|||
EOF</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
abcdefghijklmnopqrstuvwxyz |
|||
</pre> |
|||
=={{header|PL/SQL}}== |
=={{header|PL/SQL}}== |
||
< |
<syntaxhighlight lang="pl/sql">Declare |
||
sbAlphabet varchar2(100); |
sbAlphabet varchar2(100); |
||
Begin |
Begin |
||
Line 2,071: | Line 2,361: | ||
End loop; |
End loop; |
||
Dbms_Output.Put_Line(sbAlphabet); |
Dbms_Output.Put_Line(sbAlphabet); |
||
End;</ |
End;</syntaxhighlight> |
||
Output: |
Output: |
||
<pre> |
<pre> |
||
Line 2,080: | Line 2,370: | ||
Total execution time 16 ms |
Total execution time 16 ms |
||
</pre> |
</pre> |
||
=={{header|Plain English}}== |
=={{header|Plain English}}== |
||
< |
<syntaxhighlight lang="plainenglish">To run: |
||
Start up. |
Start up. |
||
Generate the lowercase ASCII alphabet giving a string. |
Generate the lowercase ASCII alphabet giving a string. |
||
Line 2,097: | Line 2,385: | ||
If the letter is the little-z byte, exit. |
If the letter is the little-z byte, exit. |
||
Add 1 to the letter. |
Add 1 to the letter. |
||
Repeat.</ |
Repeat.</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 2,104: | Line 2,392: | ||
=={{header|PowerShell}}== |
=={{header|PowerShell}}== |
||
<syntaxhighlight lang="powershell"> |
|||
<lang PowerShell> |
|||
$asString = 97..122 | ForEach-Object -Begin {$asArray = @()} -Process {$asArray += [char]$_} -End {$asArray -join('')} |
$asString = 97..122 | ForEach-Object -Begin {$asArray = @()} -Process {$asArray += [char]$_} -End {$asArray -join('')} |
||
$asString |
$asString |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{Out}} |
{{Out}} |
||
<pre> |
<pre> |
||
abcdefghijklmnopqrstuvwxyz |
abcdefghijklmnopqrstuvwxyz |
||
</pre> |
</pre> |
||
<syntaxhighlight lang="powershell"> |
|||
<lang PowerShell> |
|||
$asArray |
$asArray |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{Out}} |
{{Out}} |
||
<pre> |
<pre> |
||
Line 2,146: | Line 2,434: | ||
'''Alternative:''' |
'''Alternative:''' |
||
<syntaxhighlight lang="powershell"> |
|||
<lang PowerShell> |
|||
-join [Char[]] (97..122) |
-join [Char[]] (97..122) |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{Out}} |
{{Out}} |
||
<pre> |
<pre> |
||
Line 2,155: | Line 2,443: | ||
'''Alternative as of PowerShell-v6.0.0rc:''' |
'''Alternative as of PowerShell-v6.0.0rc:''' |
||
<syntaxhighlight lang="powershell"> |
|||
<lang PowerShell> |
|||
-join ('a'..'z') |
-join ('a'..'z') |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{Out}} |
{{Out}} |
||
<pre> |
<pre> |
||
Line 2,165: | Line 2,453: | ||
=={{header|Prolog}}== |
=={{header|Prolog}}== |
||
Works with SWI-Prolog 6.5.3 |
Works with SWI-Prolog 6.5.3 |
||
< |
<syntaxhighlight lang="prolog">a_to_z(From, To, L) :- |
||
maplist(atom_codes, [From, To], [[C_From], [C_To]]), |
maplist(atom_codes, [From, To], [[C_From], [C_To]]), |
||
bagof([C], between(C_From, C_To, C), L1), |
bagof([C], between(C_From, C_To, C), L1), |
||
maplist(atom_codes,L, L1). |
maplist(atom_codes,L, L1). |
||
</syntaxhighlight> |
|||
</lang> |
|||
Output : |
Output : |
||
<pre> ?- a_to_z(a, z, L). |
<pre> ?- a_to_z(a, z, L). |
||
Line 2,176: | Line 2,464: | ||
=={{header|Python}}== |
=={{header|Python}}== |
||
< |
<syntaxhighlight lang="python"># From the standard library: |
||
from string import ascii_lowercase |
from string import ascii_lowercase |
||
# Generation: |
# Generation: |
||
lower = [chr(i) for i in range(ord('a'), ord('z') + 1)]</ |
lower = [chr(i) for i in range(ord('a'), ord('z') + 1)]</syntaxhighlight> |
||
Or, as a particular instance of a more general enumeration pattern: |
Or, as a particular instance of a more general enumeration pattern: |
||
{{Works with|Python|3.7}} |
{{Works with|Python|3.7}} |
||
< |
<syntaxhighlight lang="python">'''Enumeration a-z''' |
||
from inspect import signature |
from inspect import signature |
||
Line 2,284: | Line 2,572: | ||
# MAIN --- |
# MAIN --- |
||
if __name__ == '__main__': |
if __name__ == '__main__': |
||
main()</ |
main()</syntaxhighlight> |
||
{{Out}} |
{{Out}} |
||
<pre>Enumeration a-z: |
<pre>Enumeration a-z: |
||
Line 2,299: | Line 2,587: | ||
The word ''constant'' causes the preceding nest to be evaluated during compilation so ''alpha$'' is a literal, not an expression computed during program evaluation. |
The word ''constant'' causes the preceding nest to be evaluated during compilation so ''alpha$'' is a literal, not an expression computed during program evaluation. |
||
< |
<syntaxhighlight lang="quackery">[ [] 26 times [ i^ char a + join ] ] constant is alpha$ ( --> $ ) |
||
alpha$ echo$</ |
alpha$ echo$</syntaxhighlight> |
||
{{Out}} |
{{Out}} |
||
Line 2,308: | Line 2,596: | ||
=={{header|R}}== |
=={{header|R}}== |
||
< |
<syntaxhighlight lang="r"># From constants built into R: |
||
letters |
letters |
||
# Or generate the same with: |
# Or generate the same with: |
||
sapply(97:122, intToUtf8)</ |
sapply(97:122, intToUtf8)</syntaxhighlight> |
||
=={{header|Racket}}== |
=={{header|Racket}}== |
||
< |
<syntaxhighlight lang="racket">(define lowercase-letters (build-list 26 (lambda (x) (integer->char (+ x (char->integer #\a))))))</syntaxhighlight> |
||
=={{header|Raku}}== |
=={{header|Raku}}== |
||
Line 2,322: | Line 2,610: | ||
{{works with|rakudo|2015-10-21}} |
{{works with|rakudo|2015-10-21}} |
||
<lang |
<syntaxhighlight lang="raku" line>say my @letters = 'a'..'z';</syntaxhighlight> |
||
* <code>'a'..'z'</code> is a range literal, it constructs an immutable <code>Range</code> object. |
* <code>'a'..'z'</code> is a range literal, it constructs an immutable <code>Range</code> object. |
||
Line 2,330: | Line 2,618: | ||
===ASCII version=== |
===ASCII version=== |
||
This version only works under ASCII machines (where the values of the lowercase '''a''' through the lowercase '''z''' characters are contiguous (and consecutive). |
This version only works under ASCII machines (where the values of the lowercase '''a''' through the lowercase '''z''' characters are contiguous (and consecutive). |
||
< |
<syntaxhighlight lang="rexx">/* REXX --------------------------------------------------------------- |
||
* 08.02.2014 Walter Pachl |
* 08.02.2014 Walter Pachl |
||
*--------------------------------------------------------------------*/ |
*--------------------------------------------------------------------*/ |
||
say xrange('a','z')</ |
say xrange('a','z')</syntaxhighlight> |
||
'''Output:''' |
'''Output:''' |
||
<pre>abcdefghijklmnopqrstuvwxyz</pre> |
<pre>abcdefghijklmnopqrstuvwxyz</pre> |
||
Line 2,347: | Line 2,635: | ||
Note that on an '''EBCDIC''' system, there are '''41''' characters between (lowercase) <big><big> a </big></big> ──► <big><big> z </big></big> |
Note that on an '''EBCDIC''' system, there are '''41''' characters between (lowercase) <big><big> a </big></big> ──► <big><big> z </big></big> |
||
<br>(inclusive), some of which don't have viewable/displayable glyphs. |
<br>(inclusive), some of which don't have viewable/displayable glyphs. |
||
< |
<syntaxhighlight lang="rexx">/*REXX program creates an indexable string of lowercase ASCII or EBCDIC characters: a─►z*/ |
||
$= /*set lowercase letters list to null. */ |
$= /*set lowercase letters list to null. */ |
||
do j=0 for 2**8; _=d2c(j) /*convert decimal J to a character. */ |
do j=0 for 2**8; _=d2c(j) /*convert decimal J to a character. */ |
||
if datatype(_, 'L') then $=$ || _ /*Is lowercase? Then add it to $ list.*/ |
if datatype(_, 'L') then $=$ || _ /*Is lowercase? Then add it to $ list.*/ |
||
end /*j*/ /* [↑] add lowercase letters ──► $ */ |
end /*j*/ /* [↑] add lowercase letters ──► $ */ |
||
say $ /*stick a fork in it, we're all done. */</ |
say $ /*stick a fork in it, we're all done. */</syntaxhighlight> |
||
'''output''' |
'''output''' |
||
<pre> |
<pre> |
||
Line 2,359: | Line 2,647: | ||
=={{header|Ring}}== |
=={{header|Ring}}== |
||
< |
<syntaxhighlight lang="ring">for i in 'a':'z' |
||
put i |
put i |
||
next</ |
next</syntaxhighlight> |
||
=={{header|RPL}}== |
|||
≪ "" |
|||
"a" NUM "z" NUM '''FOR''' ascii |
|||
ascii CHR + '''NEXT''' |
|||
≫ EVAL |
|||
{{out}} |
|||
<pre> |
|||
1: "abcdefghijklmnopqrstuvwxyz" |
|||
</pre> |
|||
=={{header|Ruby}}== |
=={{header|Ruby}}== |
||
< |
<syntaxhighlight lang="ruby">p ('a' .. 'z').to_a |
||
p [*'a' .. 'z']</ |
p [*'a' .. 'z']</syntaxhighlight> |
||
=={{header|Rust}}== |
=={{header|Rust}}== |
||
< |
<syntaxhighlight lang="rust">fn main() { |
||
// An iterator over the lowercase alpha's |
// An iterator over the lowercase alpha's |
||
let ascii_iter = (0..26) |
let ascii_iter = (0..26) |
||
Line 2,374: | Line 2,672: | ||
println!("{:?}", ascii_iter.collect::<Vec<char>>()); |
println!("{:?}", ascii_iter.collect::<Vec<char>>()); |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 2,382: | Line 2,680: | ||
=={{header|S-lang}}== |
=={{header|S-lang}}== |
||
Char_Type is just an integer-type so a "range array" can be easily created: |
Char_Type is just an integer-type so a "range array" can be easily created: |
||
< |
<syntaxhighlight lang="s-lang">variable alpha_ch = ['a':'z'], a;</syntaxhighlight> |
||
If you need single-char strings, convert thusly: |
If you need single-char strings, convert thusly: |
||
< |
<syntaxhighlight lang="s-lang">variable alpha_st = array_map(String_Type, &char, alpha_ch);</syntaxhighlight> |
||
Let's take a peek: |
Let's take a peek: |
||
< |
<syntaxhighlight lang="s-lang">print(alpha_st[23]); |
||
foreach a (alpha_ch) |
foreach a (alpha_ch) |
||
() = printf("%c ", a); |
() = printf("%c ", a); |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{out}} |
{{out}} |
||
<pre>"x" |
<pre>"x" |
||
Line 2,396: | Line 2,694: | ||
=={{header|Scala}}== |
=={{header|Scala}}== |
||
{{libheader|Scala}} |
{{libheader|Scala}} |
||
< |
<syntaxhighlight lang="scala">object Abc extends App { |
||
val lowAlpha = 'a' to 'z' //That's all |
val lowAlpha = 'a' to 'z' //That's all |
||
// Now several tests |
// Now several tests |
||
Line 2,413: | Line 2,711: | ||
scala.compat.Platform.currentTime - executionStart |
scala.compat.Platform.currentTime - executionStart |
||
} ms]") |
} ms]") |
||
}</ |
}</syntaxhighlight>{{out}} |
||
Successfully completed without errors. [within 675 ms] |
Successfully completed without errors. [within 675 ms] |
||
Line 2,420: | Line 2,718: | ||
=={{header|Scheme}}== |
=={{header|Scheme}}== |
||
{{works with|Gauche Scheme}} |
{{works with|Gauche Scheme}} |
||
< |
<syntaxhighlight lang="scheme">(map integer->char (iota 26 (char->integer #\a)))</syntaxhighlight> |
||
{{output}} |
{{output}} |
||
<pre> |
<pre> |
||
Line 2,428: | Line 2,726: | ||
=={{header|Seed7}}== |
=={{header|Seed7}}== |
||
< |
<syntaxhighlight lang="seed7">$ include "seed7_05.s7i"; |
||
const proc: main is func |
const proc: main is func |
||
Line 2,439: | Line 2,737: | ||
end for; |
end for; |
||
writeln(lower); |
writeln(lower); |
||
end func;</ |
end func;</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 2,447: | Line 2,745: | ||
=={{header|Sidef}}== |
=={{header|Sidef}}== |
||
< |
<syntaxhighlight lang="ruby">var arr = 'a'..'z'; |
||
say arr.join(' ');</ |
say arr.join(' ');</syntaxhighlight> |
||
=={{header|Smalltalk}}== |
=={{header|Smalltalk}}== |
||
< |
<syntaxhighlight lang="smalltalk">| asciiLower | |
||
asciiLower := String new. |
asciiLower := String new. |
||
97 to: 122 do: [:asciiCode | |
97 to: 122 do: [:asciiCode | |
||
asciiLower := asciiLower , asciiCode asCharacter |
asciiLower := asciiLower , asciiCode asCharacter |
||
]. |
]. |
||
^asciiLower</ |
^asciiLower</syntaxhighlight> |
||
=={{header|Snobol}}== |
=={{header|Snobol}}== |
||
< |
<syntaxhighlight lang="sml"> &ALPHABET ('a' LEN(25)) . OUTPUT ;* Works in ASCII but not EBCDIC.</syntaxhighlight> |
||
=={{header|SPL}}== |
=={{header|SPL}}== |
||
< |
<syntaxhighlight lang="spl">> i, 1..26 |
||
d = [i+96,0] |
d = [i+96,0] |
||
a[i] = #.str(d) |
a[i] = #.str(d) |
||
Line 2,470: | Line 2,768: | ||
> i, 1..#.size(a,1) |
> i, 1..#.size(a,1) |
||
#.output(a[i],#.rs) |
#.output(a[i],#.rs) |
||
<</ |
<</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 2,477: | Line 2,775: | ||
=={{header|Standard ML}}== |
=={{header|Standard ML}}== |
||
< |
<syntaxhighlight lang="sml">val lowercase_letters = List.tabulate (26, fn x => chr (x + ord #"a"));</syntaxhighlight> |
||
=={{header|Stata}}== |
=={{header|Stata}}== |
||
< |
<syntaxhighlight lang="stata">// built-in: lowercase and uppercase letters |
||
display c(alpha) |
display c(alpha) |
||
display c(ALPHA) |
display c(ALPHA) |
||
Line 2,492: | Line 2,790: | ||
mata |
mata |
||
char(97..122) |
char(97..122) |
||
end</ |
end</syntaxhighlight> |
||
=={{header|SuperCollider}}== |
=={{header|SuperCollider}}== |
||
Previously, it was claimed that the method that maps ascii number to character is polymorphic on collections. However, that doesn't seem to be the case – at least not anymore in the newer version (3.10.2). A fix was added below the original code. |
Previously, it was claimed that the method that maps ascii number to character is polymorphic on collections. However, that doesn't seem to be the case – at least not anymore in the newer version (3.10.2). A fix was added below the original code. |
||
<syntaxhighlight lang="supercollider"> |
|||
<lang SuperCollider> |
|||
(97..122).asAscii; // This example unfortunately throws an error |
(97..122).asAscii; // This example unfortunately throws an error |
||
// for me when running it on version 3.10.2 |
// for me when running it on version 3.10.2 |
||
Line 2,516: | Line 2,814: | ||
</syntaxhighlight> |
|||
</lang> |
|||
Backwards: |
Backwards: |
||
<syntaxhighlight lang="supercollider"> |
|||
<lang SuperCollider> |
|||
"abcdefghijklmnopqrstuvwxyz".ascii |
"abcdefghijklmnopqrstuvwxyz".ascii |
||
// answers [ 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122 ] |
// answers [ 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122 ] |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Swift}}== |
=={{header|Swift}}== |
||
< |
<syntaxhighlight lang="swift">var letters = [Character]() |
||
for i in 97...122 { |
for i in 97...122 { |
||
let char = Character(UnicodeScalar(i)) |
let char = Character(UnicodeScalar(i)) |
||
letters.append(char) |
letters.append(char) |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Tcl}}== |
=={{header|Tcl}}== |
||
The most common way of doing this in Tcl would be to use a simple literal; it's only 51 characters after all: |
The most common way of doing this in Tcl would be to use a simple literal; it's only 51 characters after all: |
||
< |
<syntaxhighlight lang="tcl">set alpha {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}</syntaxhighlight> |
||
Though it could be done like this as well: |
Though it could be done like this as well: |
||
< |
<syntaxhighlight lang="tcl">set alpha [apply {{} { |
||
scan "az" "%c%c" from to |
scan "az" "%c%c" from to |
||
for {set i $from} {$i <= $to} {incr i} { |
for {set i $from} {$i <= $to} {incr i} { |
||
Line 2,541: | Line 2,839: | ||
} |
} |
||
return $l |
return $l |
||
}}]</ |
}}]</syntaxhighlight> |
||
=={{header|UNIX Shell}}== |
=={{header|UNIX Shell}}== |
||
In bash or ksh93 with <tt>braceexpand</tt> set: |
In bash or ksh93 with <tt>braceexpand</tt> set: |
||
< |
<syntaxhighlight lang="sh">lower=({a..z})</syntaxhighlight> |
||
In zsh with <tt>braceccl</tt> set: |
In zsh with <tt>braceccl</tt> set: |
||
< |
<syntaxhighlight lang="sh">lower=({a-z})</syntaxhighlight> |
||
Either way, you can display the result like this: |
Either way, you can display the result like this: |
||
< |
<syntaxhighlight lang="sh">echo "${lower[@]}"</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</pre> |
{{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</pre> |
||
Line 2,558: | Line 2,856: | ||
=={{header|Ursa}}== |
=={{header|Ursa}}== |
||
Creates a string named low containing the lower case ASCII alphabet. |
Creates a string named low containing the lower case ASCII alphabet. |
||
< |
<syntaxhighlight lang="ursa">decl int i |
||
decl string low |
decl string low |
||
for (set i (ord "a")) (< i (+ (ord "z") 1)) (inc i) |
for (set i (ord "a")) (< i (+ (ord "z") 1)) (inc i) |
||
set low (+ low (chr i)) |
set low (+ low (chr i)) |
||
end for |
end for |
||
out low endl console</ |
out low endl console</syntaxhighlight> |
||
=={{header|VBA}}== |
=={{header|VBA}}== |
||
Line 2,570: | Line 2,868: | ||
{{works with|Visual Basic|6}} |
{{works with|Visual Basic|6}} |
||
<syntaxhighlight lang="vb"> |
|||
<lang vb> |
|||
Option Explicit |
Option Explicit |
||
Line 2,590: | Line 2,888: | ||
Erase strarrTemp |
Erase strarrTemp |
||
End Function |
End Function |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{out}} |
{{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</pre> |
<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</pre> |
||
=={{header|VBScript}}== |
=={{header|VBScript}}== |
||
< |
<syntaxhighlight lang="vb">Function ASCII_Sequence(range) |
||
arr = Split(range,"..") |
arr = Split(range,"..") |
||
For i = Asc(arr(0)) To Asc(arr(1)) |
For i = Asc(arr(0)) To Asc(arr(1)) |
||
Line 2,603: | Line 2,901: | ||
WScript.StdOut.Write ASCII_Sequence(WScript.Arguments(0)) |
WScript.StdOut.Write ASCII_Sequence(WScript.Arguments(0)) |
||
WScript.StdOut.WriteLine</ |
WScript.StdOut.WriteLine</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>C:\>cscript /nologo ascii_sequence.vbs a..z |
<pre>C:\>cscript /nologo ascii_sequence.vbs a..z |
||
Line 2,610: | Line 2,908: | ||
C:\>cscript /nologo ascii_sequence.vbs A..F |
C:\>cscript /nologo ascii_sequence.vbs A..F |
||
A B C D E F</pre> |
A B C D E F</pre> |
||
=={{header|Verilog}}== |
|||
<syntaxhighlight lang="verilog">module main; |
|||
integer i; |
|||
initial begin |
|||
for(i = 97; i <= 122; i=i+1) |
|||
begin |
|||
$write("%c ",i); |
|||
end |
|||
$finish ; |
|||
end |
|||
endmodule |
|||
</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 </pre> |
|||
=={{header|Vim Script}}== |
=={{header|Vim Script}}== |
||
< |
<syntaxhighlight lang="vim">let lower = [] |
||
for c in range(0, 25) |
for c in range(0, 25) |
||
let lower += [nr2char(c + char2nr("a"))] |
let lower += [nr2char(c + char2nr("a"))] |
||
endfor</ |
endfor</syntaxhighlight> |
||
or: |
or: |
||
< |
<syntaxhighlight lang="vim">echo map(range(char2nr('a'), char2nr('z')), 'nr2char(v:val)')</syntaxhighlight> |
||
=={{header|Visual Basic}}== |
=={{header|Visual Basic}}== |
||
Line 2,630: | Line 2,945: | ||
String.Join() is used to print the list, converted to array, without looping through it. |
String.Join() is used to print the list, converted to array, without looping through it. |
||
< |
<syntaxhighlight lang="vbnet">Module LowerASCII |
||
Sub Main() |
Sub Main() |
||
Line 2,641: | Line 2,956: | ||
End Module |
End Module |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{out}} |
{{out}} |
||
Line 2,647: | Line 2,962: | ||
abcdefghijklmnopqrstuvwxyz |
abcdefghijklmnopqrstuvwxyz |
||
</pre> |
</pre> |
||
=={{header|V (Vlang)}}== |
|||
<syntaxhighlight lang="v (vlang)">fn loweralpha() string { |
|||
mut p := []u8{len: 26} |
|||
for i in 97..123 { |
|||
p[i-97] = u8(i) |
|||
} |
|||
return p.bytestr() |
|||
}</syntaxhighlight> |
|||
=={{header|WebAssembly}}== |
|||
<syntaxhighlight lang="webassembly">(module $lowercase |
|||
(import "wasi_unstable" "fd_write" |
|||
(func $fd_write (param i32 i32 i32 i32) (result i32)) |
|||
) |
|||
(memory 1) |
|||
(export "memory" (memory 0)) |
|||
(func $main (export "_start") |
|||
(local $i i32) |
|||
(i32.store (i32.const 0) (i32.const 8)) ;; offset to start of string |
|||
(i32.store (i32.const 4) (i32.const 27)) ;; string length |
|||
(set_local $i (i32.const 0)) |
|||
(loop |
|||
;; mem[i+8] = i+97 |
|||
(i32.store (i32.add (get_local $i) (i32.const 8)) (i32.add (get_local $i) (i32.const 97))) |
|||
;; i = i+1 |
|||
(set_local $i (i32.add (get_local $i) (i32.const 1))) |
|||
;; if i < 26 then loop |
|||
(br_if 0 (i32.lt_s (get_local $i) (i32.const 26))) |
|||
) |
|||
;; append a newline |
|||
(i32.store (i32.add (get_local $i) (i32.const 8)) (i32.const 10)) |
|||
;; write to stdout |
|||
(call $fd_write |
|||
(i32.const 1) ;; output stream to write to (1 == stdout) |
|||
(i32.const 0) ;; memory location containing string offset and length |
|||
(i32.const 1) ;; number of strings to write |
|||
(i32.const 40) ;; location in memory to write number of bytes written |
|||
) |
|||
drop |
|||
) |
|||
)</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
abcdefghijklmnopqrstuvwxyz |
|||
</pre> |
|||
=={{header|Wren}}== |
=={{header|Wren}}== |
||
< |
<syntaxhighlight lang="wren">var alpha = [] |
||
for (c in 97..122) alpha.add(String.fromByte(c)) |
for (c in 97..122) alpha.add(String.fromByte(c)) |
||
System.print(alpha.join())</ |
System.print(alpha.join())</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 2,659: | Line 3,028: | ||
=={{header|xEec}}== |
=={{header|xEec}}== |
||
< |
<syntaxhighlight lang="xeec">h$` h$` >0_0 t h$y ms p h? jn00_0 p r h#1 ma t jn0_0 >00_0 p p r p</syntaxhighlight> |
||
=={{header|XLISP}}== |
=={{header|XLISP}}== |
||
< |
<syntaxhighlight lang="lisp">(defun ascii-lower () |
||
(defun add-chars (x y s) |
(defun add-chars (x y s) |
||
(if (<= x y) |
(if (<= x y) |
||
(add-chars (+ x 1) y (string-append s (string (integer->char x)))) |
(add-chars (+ x 1) y (string-append s (string (integer->char x)))) |
||
s)) |
s)) |
||
(add-chars 97 122 ""))</ |
(add-chars 97 122 ""))</syntaxhighlight> |
||
=={{header|XPL0}}== |
=={{header|XPL0}}== |
||
< |
<syntaxhighlight lang="xpl0">char I, A(26); |
||
for I:= 0 to 26-1 do A(I):= I+^a</ |
for I:= 0 to 26-1 do A(I):= I+^a</syntaxhighlight> |
||
=={{header|Z80 Assembly}}== |
=={{header|Z80 Assembly}}== |
||
< |
<syntaxhighlight lang="z80"> org &8000 |
||
ld a,'a' ;data |
ld a,'a' ;data |
||
ld b,26 ;loop counter |
ld b,26 ;loop counter |
||
Line 2,691: | Line 3,060: | ||
Alphabet: |
Alphabet: |
||
ds 26,0 ;reserve 26 bytes of ram, init all to zero.</ |
ds 26,0 ;reserve 26 bytes of ram, init all to zero.</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 2,704: | Line 3,073: | ||
=={{header|zkl}}== |
=={{header|zkl}}== |
||
< |
<syntaxhighlight lang="zkl">["a".."z"] // lasy list |
||
["a".."z"].walk() //-->L("a","b","c","d","e",... |
["a".."z"].walk() //-->L("a","b","c","d","e",... |
||
"a".toAsc().pump(26,List,"toChar") // another way to create the list |
"a".toAsc().pump(26,List,"toChar") // another way to create the list |
||
"a".toAsc().pump(26,String,"toChar") // create a string |
"a".toAsc().pump(26,String,"toChar") // create a string |
||
//-->"abcdefghijklmnopqrstuvwxyz" |
//-->"abcdefghijklmnopqrstuvwxyz" |
||
Utils.Helpers.lowerLetters // string const</ |
Utils.Helpers.lowerLetters // string const</syntaxhighlight> |
||
=={{header|Zig}}== |
|||
<syntaxhighlight lang="zig">const std = @import("std"); |
|||
pub fn main() !void { |
|||
const cnt_lower = 26; |
|||
var lower: [cnt_lower]u8 = undefined; |
|||
comptime var i = 0; |
|||
inline while (i < cnt_lower) : (i += 1) |
|||
lower[i] = i + 'a'; |
|||
const stdout_wr = std.io.getStdOut().writer(); |
|||
for (lower) |l| |
|||
try stdout_wr.print("{c} ", .{l}); |
|||
try stdout_wr.writeByte('\n'); |
|||
}</syntaxhighlight> |
Latest revision as of 18:08, 2 August 2024
![Task](http://static.miraheze.org/rosettacodewiki/thumb/b/ba/Rcode-button-task-crushed.png/64px-Rcode-button-task-crushed.png)
You are encouraged to solve this task according to the task description, using any language you may know.
- Task
Generate an array, list, lazy sequence, or even an indexable string of all the lower case ASCII characters, from a to z. If the standard library contains such a 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 very large program, and use strong typing if available. It's bug prone to enumerate all the lowercase characters manually in the code.
During code review it's not immediate obvious to spot the bug in a Tcl line like this contained in a page of code:
set alpha {a b c d e f g h i j k m n o p q r s t u v w x y z}
- Metrics
- Counting
- Word frequency
- Letter frequency
- Jewels and stones
- I before E except after C
- Bioinformatics/base count
- Count occurrences of a substring
- Count how many vowels and consonants occur in a string
- Remove/replace
- XXXX redacted
- Conjugate a Latin verb
- Remove vowels from a string
- String interpolation (included)
- Strip block comments
- Strip comments from a string
- Strip a set of characters from a string
- Strip whitespace from a string -- top and tail
- Strip control codes and extended characters from a string
- Anagrams/Derangements/shuffling
- Word wheel
- ABC problem
- Sattolo cycle
- Knuth shuffle
- Ordered words
- Superpermutation minimisation
- Textonyms (using a phone text pad)
- Anagrams
- Anagrams/Deranged anagrams
- Permutations/Derangements
- Find/Search/Determine
- ABC words
- Odd words
- Word ladder
- Semordnilap
- Word search
- Wordiff (game)
- String matching
- Tea cup rim text
- Alternade words
- Changeable words
- State name puzzle
- String comparison
- Unique characters
- Unique characters in each string
- Extract file extension
- Levenshtein distance
- Palindrome detection
- Common list elements
- Longest common suffix
- Longest common prefix
- Compare a list of strings
- Longest common substring
- Find common directory path
- Words from neighbour ones
- Change e letters to i in words
- Non-continuous subsequences
- Longest common subsequence
- Longest palindromic substrings
- Longest increasing subsequence
- Words containing "the" substring
- Sum of the digits of n is substring of n
- Determine if a string is numeric
- Determine if a string is collapsible
- Determine if a string is squeezable
- Determine if a string has all unique characters
- Determine if a string has all the same characters
- Longest substrings without repeating characters
- Find words which contains all the vowels
- Find words which contain the most consonants
- Find words which contains more than 3 vowels
- Find words whose first and last three letters are equal
- Find words with alternating vowels and consonants
- Formatting
- Substring
- Rep-string
- Word wrap
- String case
- Align columns
- Literals/String
- Repeat a string
- Brace expansion
- Brace expansion using ranges
- Reverse a string
- Phrase reversals
- Comma quibbling
- Special characters
- String concatenation
- Substring/Top and tail
- Commatizing numbers
- Reverse words in a string
- Suffixation of decimal numbers
- Long literals, with continuations
- Numerical and alphabetical suffixes
- Abbreviations, easy
- Abbreviations, simple
- Abbreviations, automatic
- Song lyrics/poems/Mad Libs/phrases
- Mad Libs
- Magic 8-ball
- 99 bottles of beer
- The Name Game (a song)
- The Old lady swallowed a fly
- The Twelve Days of Christmas
- Tokenize
- Text between
- Tokenize a string
- Word break problem
- Tokenize a string with escaping
- Split a character string based on change of character
- Sequences
0815
This creates the list in the queue
<:61:~}:000:>>&{~<:7a:-#:001:<:1:+^:000:
11l
print(Array(‘a’..‘z’))
- Output:
[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]
360 Assembly
In EBCDIC coding there are more than 24 characters between a and z. So we have to get rid of characters between i and j and also between r and s.
* Generate lower case alphabet - 15/10/2015
LOWER CSECT
USING LOWER,R15 set base register
LA R7,PG pgi=@pg
SR R6,R6 clear
IC R6,=C'a' char='a'
BCTR R6,0 char=char-1
LOOP LA R6,1(R6) char=char+1
STC R6,CHAR
CLI CHAR,C'i' if char>'i'
BNH OK
CLI CHAR,C'j' and char<'j'
BL SKIP then skip
CLI CHAR,C'r' if char>'r'
BNH OK
CLI CHAR,C's' and char<'s'
BL SKIP then skip
OK MVC 0(1,R7),CHAR output char
LA R7,1(R7) pgi=pgi+1
SKIP CLI CHAR,C'z' if char='z'
BNE LOOP loop
XPRNT PG,26 print buffer
XR R15,R15 set return code
BR R14 return to caller
CHAR DS C character
PG DS CL26 buffer
YREGS
END LOWER
- Output:
abcdefghijklmnopqrstuvwxyz
6502 Assembly
Stores the lower-case ASCII alphabet as a null-terminated string beginning at address 2000 hex. Register contents are preserved.
ASCLOW: PHA ; push contents of registers that we
TXA ; shall be using onto the stack
PHA
LDA #$61 ; ASCII "a"
LDX #$00
ALLOOP: STA $2000,X
INX
CLC
ADC #$01
CMP #$7B ; have we got beyond ASCII "z"?
BNE ALLOOP
LDA #$00 ; terminate the string with ASCII NUL
STA $2000,X
PLA ; retrieve register contents from
TAX ; the stack
PLA
RTS ; return
68000 Assembly
Stores the lower-case ASCII alphabet as a null-terminated string beginning at address 100000 hex. Register contents are preserved.
Called as a subroutine (i.e. "JSR Ascii_Low" if far away or "BSR Ascii_Low" if nearby)
Ascii_Low:
MOVEM.L D0/A0,-(SP) ;store D0 and A0 on stack
LEA $00100000,A0 ;could also have used MOVE.L since the address is static
MOVE.B #$61,D0 ;ascii "a"
loop_AsciiLow:
MOVE.B D0,(A0)+ ;store letter in address and increment pointer by 1
ADDQ.B #1,D0 ;add 1 to D0 to get the next letter
CMP.B #$7B,D0 ;Are we done yet? (7B is the first character after lowercase "z")
BNE loop_AsciiLow ;if not, loop again
MOVE.B #0,(A0) ;store the null terminator
MOVEM.L (SP)+,D0/A0 ;pop D0 and A0
rts
8080 Assembly
This routine takes a memory location in HL, and stores the alphabet there
in the form of an $
-terminated string that CP/M syscalls can use.
org 100h
jmp test
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Store the lowercase alphabet as a CP/M string
;; ($-terminated), starting at HL.
;; Destroys: b, c
alph: lxi b,611ah ; set B='a' and C=26 (counter)
aloop: mov m,b ; store letter in memory
inr b ; next letter
inx h ; next memory position
dcr c ; one fewer letter left
jnz aloop ; go do the next letter if there is one
mvi m,'$' ; terminate the string
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Test code
test: lxi h,buf ; select buffer
call alph ; generate alphabet
lxi d,buf ; print string in buffer
mvi c,9
call 5
rst 0
buf: ds 27 ; buffer to keep the alphabet in
8086 Assembly
bits 16
cpu 8086
org 100h
section .text
jmp demo
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Store the lowercase alphabet starting at [ES:DI]
;;; Destroys AX, CX, DI
alph: mov cx,13 ; 2*13 words = 26 bytes
mov ax,'ab' ; Do two bytes at once
.loop: stosw ; Store AX at ES:DI and add 2 to DI
add ax,202h ; Add 2 to both bytes (CD, EF, ...)
loop .loop
mov al,'$' ; MS-DOS string terminator
stosb
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
demo: mov di,buf ; Pointer to buffer
call alph ; Generate the alphabet
mov dx,buf ; Print the contents of the buffer
mov ah,9
int 21h
ret
section .bss
buf: resb 27 ; Buffer to store the alphabet in
8th
We take an empty string, and use the "loop" word to create a new character using "'a n:+". The loop passes the current index to the code being iterated, so it starts with 0 and up to 25, adding to the "'a" - which is the numeric value of lowercase "a", and the resultant number is then appended to the string. That converts the number to the appropriate character and appends it:
"" ( 'a n:+ s:+ ) 0 25 loop
. cr
- Output:
abcdefghijklmnopqrstuvwxyz
ABAP
Example with simple write statement
REPORT lower_case_ascii.
WRITE: / to_lower( sy-abcde ).
Example with / without space using CL_DEMO_OUTPUT class
REPORT lower_case_ascii.
cl_demo_output=>new(
)->begin_section( |Generate lower case ASCII alphabet|
)->write( REDUCE string( INIT out TYPE string
FOR char = 1 UNTIL char > strlen( sy-abcde )
NEXT out = COND #( WHEN out IS INITIAL THEN sy-abcde(1)
ELSE |{ out } { COND string( WHEN char <> strlen( sy-abcde ) THEN sy-abcde+char(1) ) }| ) )
)->write( |Or use the system field: { sy-abcde }|
)->display( ).
Action!
byte X
Proc Main()
For X=97 To 122
Do
Put(x)
Od
Return
- Output:
abcdefghijklmnopqrstuvwxyz
Ada
We start with a strong type definition: A character range that can only hold lower-case letters:
type Lower_Case is new Character range 'a' .. 'z';
Now we define an array type and initialize the Array A of that type with the 26 letters:
type Arr_Type is array (Integer range <>) of Lower_Case;
A : Arr_Type (1 .. 26) := "abcdefghijklmnopqrstuvwxyz";
Strong typing would catch two errors: (1) any upper-case letters or other symbols in the string assigned to A, and (2) too many or too few letters assigned to A. However, a letter might still appear twice (or more) in A, at the cost of one or more other letters. Array B is safe even against such errors:
B : Arr_Type (1 .. 26);
begin
B(B'First) := 'a';
for I in B'First .. B'Last-1 loop
B(I+1) := Lower_Case'Succ(B(I));
end loop; -- now all the B(I) are different
ALGOL 68
# in ALGOL 68, a STRING is an array of characters with flexible bounds #
# so we can declare an array of 26 characters and assign a string #
# containing the lower-case letters to it #
[ 26 ]CHAR lc := "abcdefghijklmnopqrstuvwxyz"
Alternative version
# fills lc with the 26 lower-case letters, assuming that #
# they are consecutive in the character set, as they are in ASCII #
[ 26 ]CHAR lc;
FOR i FROM LWB lc TO UPB lc
DO
lc[ i ] := REPR ( ABS "a" + ( i - 1 ) )
OD
ALGOL W
% set lc to the lower case alphabet %
string(26) lc;
for c := 0 until 25 do lc( c // 1 ) := code( decode( "a" ) + c );
APL
⎕UCS 96+⍳26
AppleScript
-------------------- ALPHABETIC SERIES -------------------
on run
unlines(map(concat, ¬
({enumFromTo("a", "z"), ¬
enumFromTo("🐟", "🐐"), ¬
enumFromTo("z", "a"), ¬
enumFromTo("α", "ω")})))
end run
-------------------- GENERIC FUNCTIONS -------------------
-- concat :: [[a]] -> [a]
-- concat :: [String] -> String
on concat(xs)
set lng to length of xs
if 0 < lng and string is class of (item 1 of xs) then
set acc to ""
else
set acc to {}
end if
repeat with i from 1 to lng
set acc to acc & item i of xs
end repeat
acc
end concat
-- enumFromTo :: Enum a => a -> a -> [a]
on enumFromTo(m, n)
if class of m is integer then
enumFromToInt(m, n)
else
enumFromToChar(m, n)
end if
end enumFromTo
-- enumFromToChar :: Char -> Char -> [Char]
on enumFromToChar(m, n)
set {intM, intN} to {id of m, id of n}
set xs to {}
repeat with i from intM to intN by signum(intN - intM)
set end of xs to character id i
end repeat
return xs
end enumFromToChar
-- mReturn :: First-class m => (a -> b) -> m (a -> b)
on mReturn(f)
-- 2nd class handler function lifted into 1st class script wrapper.
if script is class of f then
f
else
script
property |λ| : f
end script
end if
end mReturn
-- map :: (a -> b) -> [a] -> [b]
on map(f, xs)
-- The list obtained by applying f
-- to each element of xs.
tell mReturn(f)
set lng to length of xs
set lst to {}
repeat with i from 1 to lng
set end of lst to |λ|(item i of xs, i, xs)
end repeat
return lst
end tell
end map
-- signum :: Num -> Num
on signum(x)
if x < 0 then
-1
else if x = 0 then
0
else
1
end if
end signum
-- unlines :: [String] -> String
on unlines(xs)
-- A single string formed by the intercalation
-- of a list of strings with the newline character.
set {dlm, my text item delimiters} to ¬
{my text item delimiters, linefeed}
set s to xs as text
set my text item delimiters to dlm
s
end unlines
- Output:
abcdefghijklmnopqrstuvwxyz 🐟🐞🐝🐜🐛🐚🐙🐘🐗🐖🐕🐔🐓🐒🐑🐐 zyxwvutsrqponmlkjihgfedcba αβγδεζηθικλμνξοπρςστυφχψω
A minor variation would be to perform a mass conversion and character extraction at the end instead of twenty-six individual character id i conversions:
set l to {}
repeat with i from id of "a" to id of "z"
set end of l to i
end repeat
return characters of string id l
- Output:
{"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"}
Applesoft BASIC
L$="abcdefghijklmnopqrstuvwxyz"
On the older model Apple II and Apple II plus, it is difficult to enter lower case characters. The following code generates the same string:
L$="":FORI=1TO26:L$=L$+CHR$(96+I):NEXT
ARM Assembly
Uses VASM syntax. PrintString
routine courtesy of Chibiakumas
Hardware: Game Boy Advance (ARM7TDMI)
This code generates the lower case ASCII set, stores it in RAM as a string literal, and prints that string to the screen.
ProgramStart:
mov sp,#0x03000000 ;Init Stack Pointer
mov r4,#0x04000000 ;DISPCNT -LCD Control
mov r2,#0x403 ;4= Layer 2 on / 3= ScreenMode 3
str r2,[r4] ;hardware specific routine, activates Game Boy's bitmap mode
mov r0,#0x61 ;ASCII "a"
mov r2,#ramarea
mov r1,#26
rep_inc_stosb: ;repeatedly store a byte into memory, incrementing the destination and the value stored
; each time.
strB r0,[r2]
add r0,r0,#1
add r2,r2,#1
subs r1,r1,#1
bne rep_inc_stosb
mov r0,#255
strB r0,[r2] ;store a 255 terminator into r1
mov r1,#ramarea
bl PrintString ;Prints a 255-terminated string using a pre-defined bitmap font. Code omitted for brevity
forever:
b forever ;halt the cpu
- Output:
Arturo
print to [:char] 97..122
- Output:
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
ATS
(* ****** ****** *)
//
// How to compile:
//
// patscc -DATS_MEMALLOC_LIBC -o lowercase lowercase.dats
//
(* ****** ****** *)
//
#include
"share/atspre_staload.hats"
//
(* ****** ****** *)
implement
main0 () =
{
//
val N = 26
//
val A =
arrayref_tabulate_cloref<char>
(
i2sz(N), lam(i) => int2char0(char2int0('a') + sz2i(i))
) (* end of [val] *)
//
} (* end of [main0] *)
AutoHotkey
a :={}
Loop, 26
a.Insert(Chr(A_Index + 96))
AutoIt
Func _a2z()
Local $a2z = ""
For $i = 97 To 122
$a2z &= Chr($i)
Next
Return $a2z
EndFunc
AWK
Generate all character codes, and test each one if it matches the POSIX character class for "lowercase".
Note this is dependent on the locale-setting, and options, e.g. --traditional and --posix
# syntax: GAWK -f GENERATE_LOWER_CASE_ASCII_ALPHABET.AWK
BEGIN {
for (i=0; i<=255; i++) {
c = sprintf("%c",i)
if (c ~ /[[:lower:]]/) {
lower_chars = lower_chars c
}
}
printf("%s %d: %s\n",ARGV[0],length(lower_chars),lower_chars)
exit(0)
}
- Output:
gawk_3_1_8 26: abcdefghijklmnopqrstuvwxyz gawk_4_1_0 65: abcdefghijklmnopqrstuvwxyzƒsozªµºßàáâaäåæçèéêëìíîïdñòóôoöoùúûüy_ÿ
BASIC
BBC BASIC
DIM lower&(25)
FOR i%=0TO25
lower&(i%)=ASC"a"+i%
NEXT
END
BASIC256
# generate lowercase ascii alphabet
# basic256 1.1.4.0
dim a$(27) # populating array for possible future use
for i = 1 to 26
a$[i] = chr(i + 96)
print a$[i] + " ";
next i
- Output:
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
Commodore BASIC
10 FOR I=ASC("A") TO ASC("Z")
20 A$ = A$+CHR$(I)
30 NEXT
40 PRINT CHR$(14) : REM 'SWITCH CHARACTER SET TO LOWER/UPPER CASES
50 PRINT A$
FreeBASIC
' FB 1.05.0 Win64
' Create a string buffer to store the alphabet plus a final null byte
Dim alphabet As Zstring * 27
' ASCII codes for letters a to z are 97 to 122 respectively
For i As Integer = 0 To 25
alphabet[i] = i + 97
Next
Print alphabet
Print
Print "Press any key to quit"
Sleep
- Output:
abcdefghijklmnopqrstuvwxyz
IS-BASIC
100 STRING ALPHA$*26
110 LET ALPHA$=""
120 FOR I=ORD("a") TO ORD("z")
130 LET ALPHA$=ALPHA$&CHR$(I)
140 NEXT
150 PRINT ALPHA$
PureBasic
Dim lower_case('z' - 'a') ;indexing goes from 0 -> 25
For i = 0 To ArraySize(lower_case())
lower_case(i) = i + 'a'
Next
QBasic
DIM a$(27)
FOR i = 1 to 26
LET a$(i) = CHR$(i + 96)
PRINT a$(i);
NEXT i
END
True BASIC
DIM a$(27)
FOR i = 1 to 26
LET a$(i) = CHR$(i + 96)
PRINT a$(i);
NEXT i
END
XBasic
PROGRAM "progname"
VERSION "0.0000"
DECLARE FUNCTION Entry ()
FUNCTION Entry ()
DIM a$[27]
FOR i = 1 TO 26
a$[i] = CHR$(i + 96)
PRINT a$[i];
NEXT i
END FUNCTION
END PROGRAM
Yabasic
for i = asc("a") to asc("z")
print chr$(i);
next i
Run BASIC
for i = asc("a") to asc("z")
print chr$(i);
next i
Output:
abcdefghijklmnopqrstuvwxyz
uBasic/4tH
For x= ORD("a") To ORD("z") : @(x - ORD("a")) = x : Next
ZX Spectrum Basic
10 DIM l$(26): LET init= CODE "a"-1
20 FOR i=1 TO 26
30 LET l$(i)=CHR$ (init+i)
40 NEXT i
50 PRINT l$
BaCon
Using the inline loop construct.
PRINT LOOP$(26, CHR$(96+_))
- Output:
abcdefghijklmnopqrstuvwxyz
Batch File
@echo off
setlocal enabledelayedexpansion
:: This code appends the ASCII characters from 97-122 to %alphabet%, removing any room for error.
for /l %%i in (97,1,122) do (
cmd /c exit %%i
set "alphabet=!alphabet! !=exitcodeAscii!"
)
echo %alphabet%
pause>nul
- Output:
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
Befunge
The left hand side pushes the sequence 'a' to 'z' onto the stack in reverse order with a null terminator (a fairly typical Befunge pattern). The right hand side is just printing it out again to test.
0"z":>"a"`#v_ >:#,_$@
^:- 1:<
BQN
'a'+↕26
Bracmat
a:?seq:?c
& whl
' ( chr$(asc$!c+1):~>z:?c
& !seq !c:?seq
)
& !seq
Brainf***
Make room for 26 characters
>>>>>>>>>>>>>
>>>>>>>>>>>>>
Set counter to 26
>>
+++++++++++++
+++++++++++++
Generate the numbers 1 to 26
[-<< Decrement counter
[+<] Add one to each nonzero cell moving right to left
+ Add one to first zero cell encountered
[>]> Return head to counter
]
<<
Add 96 to each cell
[
++++++++++++++++
++++++++++++++++
++++++++++++++++
++++++++++++++++
++++++++++++++++
++++++++++++++++
<]
Print each cell
>[.>]
++++++++++. \n
Uncommented:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>++++++++++++++++++++++++++[-<<[+<]
+[>]>]<<[+++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++<]>[.>]++++++++++.
A smaller and faster solution:
++++++++++++++++++++++++++ >
++++++++++++++++++++++++++ ++++++
++++++++++++++++++++++++++ ++++++
++++++++++++++++++++++++++ ++++++
< [ - > + . < ]
- Output:
abcdefghijklmnopqrstuvwxyz
Burlesque
blsq ) @azr\sh
abcdefghijklmnopqrstuvwxyz
C
#include <stdlib.h>
#define N 26
int main() {
unsigned char lower[N];
for (size_t i = 0; i < N; i++) {
lower[i] = i + 'a';
}
return EXIT_SUCCESS;
}
C#
Simple Linq 1 liner solution
using System;
using System.Linq;
internal class Program
{
private static void Main()
{
Console.WriteLine(String.Concat(Enumerable.Range('a', 26).Select(c => (char)c)));
}
}
- Output:
abcdefghijklmnopqrstuvwxyz
Old style Property and enumerable based solution
namespace RosettaCode.GenerateLowerCaseASCIIAlphabet
{
using System;
using System.Collections.Generic;
internal class Program
{
private static IEnumerable<char> Alphabet
{
get
{
for (var character = 'a'; character <= 'z'; character++)
{
yield return character;
}
}
}
private static void Main()
{
Console.WriteLine(string.Join(string.Empty, Alphabet));
}
}
}
- Output:
abcdefghijklmnopqrstuvwxyz
C++
C++ can do the task in the identical way as C, or else, it can use a STL function.
#include <string>
#include <numeric>
int main() {
std::string lower(26,' ');
std::iota(lower.begin(), lower.end(), 'a');
}
Clojure
(map char (range (int \a) (inc (int \z))))
- Output:
(\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)
CLU
alph = proc () returns (string)
a: int := char$c2i('a')
letters: array[char] := array[char]$predict(1,26)
for i: int in int$from_to(0, 25) do
array[char]$addh(letters, char$i2c(a + i))
end
return(string$ac2s(letters))
end alph
% test
start_up = proc ()
stream$putl(stream$primary_output(), alph())
end start_up
- Output:
abcdefghijklmnopqrstuvwxyz
COBOL
Strings in COBOL are mutable and can be subscripted: each time we go round the loop, we assign to a one-character-long section of the string we are building.
identification division.
program-id. lower-case-alphabet-program.
data division.
working-storage section.
01 ascii-lower-case.
05 lower-case-alphabet pic a(26).
05 character-code pic 999.
05 loop-counter pic 99.
procedure division.
control-paragraph.
perform add-next-letter-paragraph varying loop-counter from 1 by 1
until loop-counter is greater than 26.
display lower-case-alphabet upon console.
stop run.
add-next-letter-paragraph.
add 97 to loop-counter giving character-code.
move function char(character-code) to lower-case-alphabet(loop-counter:1).
- Output:
abcdefghijklmnopqrstuvwxyz
CoffeeScript
(String.fromCharCode(x) for x in [97..122])
Comal
dim alphabet$ of 26
for i := 1 to 26
alphabet$(i) := chr$(ord("a") - 1 + i)
endfor i
print alphabet$
- Output:
abcdefghijklmnopqrstuvwxyz
Common Lisp
;; as a list
(defvar *lower*
(loop with a = (char-code #\a)
for i below 26
collect (code-char (+ a i))))
;; as a string
(defvar *lowercase-alphabet-string*
(map 'string #'code-char (loop
for c from (char-code #\a) to (char-code #\z)
collect c))
"The 26 lower case letters in alphabetical order.")
;; verify
(assert (= 26 (length *lowercase-alphabet-string*) (length *lower*)))
(assert (every #'char< *lowercase-alphabet-string* (subseq *lowercase-alphabet-string* 1)))
(assert (apply #'char< *lower*))
(assert (string= *lowercase-alphabet-string* (coerce *lower* 'string)))
Cowgol
include "cowgol.coh";
# Generate the alphabet and store it at the given location
# It is assumed that there is enough space (27 bytes)
sub alph(buf: [uint8]): (out: [uint8]) is
out := buf;
var letter: uint8 := 'a';
while letter <= 'z' loop
[buf] := letter;
letter := letter + 1;
buf := @next buf;
end loop;
[buf] := 0;
end sub;
# Use the subroutine to print the alphabet
var buf: uint8[27]; # make room for the alphabet
print(alph(&buf as [uint8]));
- Output:
abcdefghijklmnopqrstuvwxyz
D
The lower case ASCII letters of the Phobos standard library:
import std.ascii: lowercase;
void main() {}
The generation of the ASCII alphabet array:
void main() {
char['z' - 'a' + 1] arr;
foreach (immutable i, ref c; arr)
c = 'a' + i;
}
An alternative version:
void main() {
import std.range, std.algorithm, std.array;
char[26] arr = 26.iota.map!(i => cast(char)('a' + i)).array;
}
Another version:
void main() {
char[] arr;
foreach (immutable char c; 'a' .. 'z' + 1)
arr ~= c;
assert(arr == "abcdefghijklmnopqrstuvwxyz");
}
dc
Construct the numerical representation of the desired output and print it.
122 [ d 1 - d 97<L 256 * + ] d sL x P
Output:
abcdefghijklmnopqrstuvwxyz
Delphi
program atoz;
var
ch : char;
begin
for ch in ['a'..'z'] do
begin
write(ch);
end;
end.
- Output:
abcdefghijklmnopqrstuvwxyz
Draco
/* Generate the lowercase alphabet and store it in a buffer */
proc alph(*char buf) *char:
channel output text ch;
char letter;
open(ch, buf);
for letter from 'a' upto 'z' do
write(ch; letter)
od;
close(ch);
buf
corp
/* Use the function to print the alphabet */
proc main() void:
[27] char buf; /* one byte extra for the string terminator */
writeln(alph(&buf[0]))
corp
- Output:
abcdefghijklmnopqrstuvwxyz
DUP
In DUP, strings between double quotes are stored in a numerically addressed array. The integer before the first "
which gets pushed on the data stack, defines the cell address in which the ASCII value of first character of the string will be stored. All following characters will be stored like an array as values in the following cells. At the end, DUP pushes the length of the string on the data stack.
0"abcdefghijklmnopqrstuvwxyz" {store character values of string in cells 0..length of string-1}
26[$][^^-;,1-]# {Loop from 26-26 to 26-0, print the respective cell contents to STDOUT}
Output:
abcdefghijklmnopqrstuvwxyz
Dyalect
Generates a lazy sequence and prints it to a standard output:
print << ('a'..'z').ToArray()
EasyLang
# Generated on an array
for i = 97 to 122
alphabet$[] &= strchar i
.
print alphabet$[]
# Generated on a string
for i = 97 to 122
alphabet$ &= strchar i
.
print alphabet$
EchoLisp
;; 1)
(define \a (first (string->unicode "a")))
(for/list ((i 25)) (unicode->string (+ i \a)))
→ (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)
;;2) using a sequence
(lib 'sequences)
(take ["a" .. "z"] 26)
→ (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)
; or
(for/string ((letter ["a" .. "z"])) letter)
→ abcdefghijklmnopqrstuvwxyz
Elena
ELENA 6.x :
import extensions;
import system'collections;
singleton Alphabet : Enumerable
{
Enumerator enumerator() = new Enumerator
{
char current;
get Value() = current;
bool next()
{
if (nil==current)
{
current := $97
}
else if (current != $122)
{
current := (current.toInt() + 1).toChar()
}
else
{
^ false
};
^ true
}
reset()
{
current := nil
}
enumerable() = self;
};
}
public program()
{
console.printLine(Alphabet)
}
- Output:
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
Elixir
iex(1)> Enum.to_list(?a .. ?z)
'abcdefghijklmnopqrstuvwxyz'
iex(2)> Enum.to_list(?a .. ?z) |> List.to_string
"abcdefghijklmnopqrstuvwxyz"
Erlang
lists:seq($a,$z).
- Output:
"abcdefghijklmnopqrstuvwxyz"
Excel
LAMBDA
Binding the name showAlphabet to the following lambda expression in the Name Manager of the Excel WorkBook:
(See LAMBDA: The ultimate Excel worksheet function)
showAlphabet
=LAMBDA(az,
ENUMFROMTOCHAR(
MID(az, 1, 1)
)(
MID(az, 2, 1)
)
)
and also assuming the following generic binding in the Name Manager for the WorkBook:
ENUMFROMTOCHAR
=LAMBDA(a,
LAMBDA(z,
LET(
aCode, UNICODE(a),
zCode, UNICODE(z),
UNICHAR(
IF(zCode >= aCode,
SEQUENCE(
1, 1 + zCode - aCode,
aCode, 1
),
SEQUENCE(
1, 1 + aCode - zCode,
aCode, -1
)
)
)
)
)
)
- Output:
The formula in cell B2, for example, defines an array which populates the whole range B2:AA2
fx | =showAlphabet(A2) | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 | AA | AB | ||
1 | From to | ||||||||||||||||||||||||||||
2 | az | 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 | ||
3 | αω | α | β | γ | δ | ε | ζ | η | θ | ι | κ | λ | μ | ν | ξ | ο | π | ρ | ς | σ | τ | υ | φ | χ | ψ | ω | |||
4 | את | א | ב | ג | ד | ה | ו | ז | ח | ט | י | ך | כ | ל | ם | מ | ן | נ | ס | ע | ף | פ | ץ | צ | ק | ר | ש | ת | |
5 | תא | ת | ש | ר | ק | צ | ץ | פ | ף | ע | ס | נ | ן | מ | ם | ל | כ | ך | י | ט | ח | ז | ו | ה | ד | ג | ב | א | |
6 | za | z | y | x | w | v | u | t | s | r | q | p | o | n | m | l | k | j | i | h | g | f | e | d | c | b | a | ||
7 | ωα | ω | ψ | χ | φ | υ | τ | σ | ς | ρ | π | ο | ξ | ν | μ | λ | κ | ι | θ | η | ζ | ε | δ | γ | β | α |
F#
let lower = ['a'..'z']
printfn "%A" lower
Factor
Strings are represented as fixed-size mutable sequences of Unicode code points.
USING: spelling ; ! ALPHABET
ALPHABET print
0x61 0x7A [a,b] >string print
: russian-alphabet-without-io ( -- str ) 0x0430 0x0450 [a,b) >string ;
: russian-alphabet ( -- str ) 0x0451 6 russian-alphabet-without-io insert-nth ;
russian-alphabet print
- Output:
abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz абвгдеёжзийклмнопрстуфхцчшщъыьэюя
FALSE
'a[$'z>~][$,1+]#%
- Output:
abcdefghijklmnopqrstuvwxyz
Fermat
Array locase[1,26];
[locase]:=[<i=1,26>'a'+i-1];
!([locase:char);
- Output:
abcdefghijklmnopqrstuvwxyz
Forth
Generate a string filled with the lowercase ASCII alphabet
: printit 26 0 do [char] a I + emit loop ;
Or coded another way
: printit2 [char] z 1+ [char] a do I emit loop ;
We could do something more complicated and allocate space for a string and fill it. Two methods are demonstrated below
create lalpha 27 chars allot \ create a string in memory for 26 letters and count byte
: ]lalpha ( index -- addr ) \ index the string like an array (return an address)
lalpha char+ + ;
\ method 1: fill memory with ascii values using a loop
: fillit ( -- )
26 0
do
[char] a I + \ calc. the ASCII value, leave on the stack
I ]lalpha c! \ store the value on stack in the string at index I
loop
26 lalpha c! ; \ store the count byte at the head of the string
\ method 2: load with a string literal
: Loadit s" abcdefghijklmnopqrstuvwxyz" lalpha PLACE ;
- Output:
Test at the console
printit abcdefghijklmnopqrstuvwxyz ok
fillit ok
lalpha count type abcdefghijklmnopqrstuvwxyz ok
lalpha count erase ok
lalpha count type ok
loadit ok
lalpha count type abcdefghijklmnopqrstuvwxyz ok
Fortran
character(26) :: alpha
integer :: i
do i = 1, 26
alpha(i:i) = achar(iachar('a') + i - 1)
end do
Free Pascal
One can use set constructors like in Delphi. alphabet’s type will be set of char.
program lowerCaseAscii(input, output, stdErr);
const
alphabet = ['a'..'z'];
begin
end.
Note, Pascal does not define that the letters A through Z are contiguous, the set constructor above assumes that, though. However, the FPC – the FreePascal compiler – virtually only works on systems, that use at least ASCII as common denominator.
Frink
The following produces a lazy enumerating sequence of the characters.
map["char", char["a"] to char["z"]]
To produce a non-lazy array of the characters, you can wrap the above in a toArray
call:
toArray[map["char", char["a"] to char["z"]]]
Furor
#k 'a 'z ++ {|| {} print SPACE |} NL end
- Output:
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
Peri
###sysinclude standard.uh
#k 'a 'z ++ {{ , {{}} print SPACE }} NL end
- Output:
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
FutureBasic
long i
for i = asc("a") to asc("z")
print chr$(i);
next
HandleEvents
- Output:
abcdefghijklmnopqrstuvwxyz
Gambas
Click this link to run this code
Public Sub Main()
Dim siCount As Short
For siCount = Asc("a") To Asc("z")
Print Chr(siCount);
Next
End
Output:
abcdefghijklmnopqrstuvwxyz
Go
func loweralpha() string {
p := make([]byte, 26)
for i := range p {
p[i] = 'a' + byte(i)
}
return string(p)
}
Groovy
def lower = ('a'..'z')
Test
assert 'abcdefghijklmnopqrstuvwxyz' == lower.join('')
Haskell
lower = ['a' .. 'z']
main = print lower
Or, equivalently:
alpha :: String
alpha = enumFromTo 'a' 'z'
main :: IO ()
main = print alpha
- Output:
"abcdefghijklmnopqrstuvwxyz"
Hoon
`(list cord)`(gulf 97 122)
- Output:
> `(list cord)`(gulf 97 122) <|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|>
Huginn
import Algorithms as algo;
import Text as text;
main() {
print(
"{}\n".format(
text.character_class( text.CHARACTER_CLASS.LOWER_CASE_LETTER )
)
);
print(
"{}\n".format(
algo.materialize(
algo.map(
algo.range( integer( 'a' ), integer( 'z' ) + 1 ),
character
),
string
)
)
);
}
- Output:
abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz
Icon and Unicon
You can just use the keyword:
&lcase
(although this technically produces a character set instead of a string, it can be used as a string, so string subscripting, generation, etc., all work).
E.g.
every a := put([], !&lcase) # array of 1 character per element
c := create !&lcase # lazy generation of letters in sequence
Insitux
(-> (map char-code "az")
(adj _ inc)
(.. range)
(map char-code))
["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"]
J
Solution:
thru=: <. + i.@(+*)@-~
thru&.(a.&i.)/'az'
abcdefghijklmnopqrstuvwxyz
or
u:97+i.26
abcdefghijklmnopqrstuvwxyz
or
([-.toupper)a.
abcdefghijklmnopqrstuvwxyz
and, obviously, other variations are possible.
Java
char[] lowerAlphabet() {
char[] letters = new char[26];
for (int code = 97; code < 123; code++)
letters[code - 97] = (char) code;
return letters;
}
abcdefghijklmnopqrstuvwxyz
An alternate implementation
public class LowerAscii {
public static void main(String[] args) {
StringBuilder sb = new StringBuilder(26);
for (char ch = 'a'; ch <= 'z'; ch++)
sb.append(ch);
System.out.printf("lower ascii: %s, length: %s", sb, sb.length());
}
}
Output:
lower ascii: abcdefghijklmnopqrstuvwxyz, length: 26
JavaScript
ES5
In ES5, we can use String.fromCharCode(), which suffices for Unicode characters which can be represented with one 16 bit number.
For Unicode characters beyond this range, in ES5 we have to enter a pair of Unicode number escapes.
(function (cFrom, cTo) {
function cRange(cFrom, cTo) {
var iStart = cFrom.charCodeAt(0);
return Array.apply(
null, Array(cTo.charCodeAt(0) - iStart + 1)
).map(function (_, i) {
return String.fromCharCode(iStart + i);
});
}
return cRange(cFrom, cTo);
})('a', 'z');
Returns:
["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"]
ES6
In ES6, the new String.fromCodePoint() method can can return 4-byte characters (such as Emoji, for example) as well as the usual 2-byte characters.
(function (lstRanges) {
function cRange(cFrom, cTo) {
var iStart = cFrom.codePointAt(0);
return Array.apply(
null, Array(cTo.codePointAt(0) - iStart + 1)
).map(function (_, i) {
return String.fromCodePoint(iStart + i);
});
}
return lstRanges.map(function (lst) {
return cRange(lst[0], lst[1]);
});
})([
['a', 'z'],
['🐐', '🐟']
]);
Output:
[["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"],
["🐐", "🐑", "🐒", "🐓", "🐔", "🐕", "🐖", "🐗", "🐘", "🐙", "🐚", "🐛", "🐜", "🐝", "🐞", "🐟"]]
var letters = []
for (var i = 97; i <= 122; i++) {
letters.push(String.fromCodePoint(i))
}
Or, if we want to write a more general ES6 function:
(() => {
// enumFromTo :: Enum a => a -> a -> [a]
const enumFromTo = (m, n) => {
const [intM, intN] = [m, n].map(fromEnum),
f = typeof m === 'string' ? (
(_, i) => chr(intM + i)
) : (_, i) => intM + i;
return Array.from({
length: Math.floor(intN - intM) + 1
}, f);
};
// GENERIC FUNCTIONS ------------------------------------------------------
// compose :: (b -> c) -> (a -> b) -> (a -> c)
const compose = (f, g) => x => f(g(x));
// chr :: Int -> Char
const chr = x => String.fromCodePoint(x);
// ord :: Char -> Int
const ord = c => c.codePointAt(0);
// fromEnum :: Enum a => a -> Int
const fromEnum = x => {
const type = typeof x;
return type === 'boolean' ? (
x ? 1 : 0
) : type === 'string' ? ord(x) : x;
};
// map :: (a -> b) -> [a] -> [b]
const map = (f, xs) => xs.map(f);
// show :: a -> String
const show = x => JSON.stringify(x);
// uncurry :: Function -> Function
const uncurry = f => args => f.apply(null, args);
// unlines :: [String] -> String
const unlines = xs => xs.join('\n');
// unwords :: [String] -> String
const unwords = xs => xs.join(' ');
// TEST -------------------------------------------------------------------
return unlines(map(compose(unwords, uncurry(enumFromTo)), [
['a', 'z'],
['α', 'ω'],
['א', 'ת'],
['🐐', '🐟']
]));
})();
- Output:
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 α β γ δ ε ζ η θ ι κ λ μ ν ξ ο π ρ ς σ τ υ φ χ ψ ω א ב ג ד ה ו ז ח ט י ך כ ל ם מ ן נ ס ע ף פ ץ צ ק ר ש ת 🐐 🐑 🐒 🐓 🐔 🐕 🐖 🐗 🐘 🐙 🐚 🐛 🐜 🐝 🐞 🐟
Joy
'a ['z =] ["" cons] [dup succ] [cons] linrec.
jq
"az" | explode | [range( .[0]; 1+.[1] )] | implode'
produces:
"abcdefghijklmnopqrstuvwxyz"
Jsish
/* Generate the lower case alphabet with Jsish, assume ASCII */
var letterA = "a".charCodeAt(0);
var lowers = Array(26);
for (var i = letterA; i < letterA + 26; i++) {
lowers[i - letterA] = Util.fromCharCode(i);
}
puts(lowers);
puts(lowers.join(''));
puts(lowers.length);
/*
=!EXPECTSTART!=
[ "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" ]
abcdefghijklmnopqrstuvwxyz
26
=!EXPECTEND!=
*/
- Output:
prompt$ jsish generate-lowers.jsi [ "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" ] abcdefghijklmnopqrstuvwxyz 26 prompt$ jsish -u generate-lowers.jsi [PASS] generate-lowers.jsi
Julia
@show collect('a':'z')
@show join('a':'z')
- Output:
collect('a':'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'] join('a':'z') = "abcdefghijklmnopqrstuvwxyz"
K
`c$ casts a list of integers to a string of characters; !26 produces a list of the integers from 0 to 25. So the lower-case ASCII alphabet can be generated using:
`c$97+!26
- Output:
"abcdefghijklmnopqrstuvwxyz"
Keg
a(55*|:1+)
Kotlin
// version 1.3.72
fun main() {
val alphabet = CharArray(26) { (it + 97).toChar() }.joinToString("")
println(alphabet)
}
- Output:
abcdefghijklmnopqrstuvwxyz
Lambdatalk
1) We define code2char & char2code as primitives:
{script
LAMBDATALK.DICT["char2code"] = function() {
var args = arguments[0].trim();
return args.charCodeAt(0);
};
LAMBDATALK.DICT["code2char"] = function() {
var args = arguments[0].trim();
return String.fromCharCode(args);
};
}
2) and we use them:
{S.map code2char {S.serie {char2code a} {char2code 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
{S.map code2char {S.serie {char2code 0} {char2code 9}}}
-> 0 1 2 3 4 5 6 7 8 9
Lang
&alphabet = fn.arrayGenerateFrom(fn.combBX(fn.char, fn.add, a), 26)
fn.println(&alphabet)
# As string (Strings are called text in Lang)
$alphabetText = fn.join(\e, &alphabet)
fn.println($alphabetText)
- Output:
[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] abcdefghijklmnopqrstuvwxyz
LC3 Assembly
.ORIG 0x3000
LD R0,ASCIIa
LD R1,ASCIIz
NOT R1,R1
LOOP OUT
ADD R0,R0,1
ADD R2,R0,R1
BRN LOOP
HALT
ASCIIa .FILL 0x61
ASCIIz .FILL 0x7A
Output:
abcdefghijklmnopqrstuvwxyz
Lingo
alphabet = []
repeat with i = 97 to 122
alphabet.add(numtochar(i))
end repeat
put alphabet
-- ["a", "b", "c", ... , "x", "y", "z"]
Logo
Straightforward, assuming ASCII:
show map "char iseq 97 122
Slightly less straightforward, but without the magic numbers:
show map "char apply "iseq map "ascii [a z]
Same output either way:
- Output:
[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]
Lua
to table
function getAlphabet ()
local letters = {}
for ascii = 97, 122 do table.insert(letters, string.char(ascii)) end
return letters
end
local alpha = getAlphabet()
print(alpha[25] .. alpha[1] .. alpha[25])
- Output:
yay
to string
#!/usr/bin/env luajit
local function ascii(f,t) local tab={} for i=f,t do tab[#tab+1]=string.char(i) end
return table.concat(tab)
end
print(ascii(97,122))
- Output:
> ./lowercaseascii.lua abcdefghijklmnopqrstuvwxyz
M2000 Interpreter
\\ old style Basic, including a Binary.Or() function
Module OldStyle {
10 LET A$=""
20 FOR I=ASC("A") TO ASC("Z")
30 LET A$=A$+CHR$(BINARY.OR(I, 32))
40 NEXT I
50 PRINT A$
}
CALL OldStyle
Maple
seq(StringTools:-Char(c), c = 97 .. 122);
- Output:
"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"
Mathcad
Note: ":=" is the definition operator "=" is the evaluation operator
The actual Mathcad worksheet is at https://community.ptc.com/t5/PTC-Mathcad/Rosetta-Code-Generate-Lower-Case-ASCII-Alphabet/m-p/670829#M190552
The Haskell-like '--' marker preceding each comment is not necessary in Mathcad, and is only there to indicate text rather than an expression.
Method 1: Using a Range Variable.
-- user-defined function that returns the ASCII code for string character ch.
code(ch):=str2vec(ch)[0
-- number of lower-case ASCII characters
N:=26
-- range variable covering the relative indices of the lower-case characters within the ASCII character set (0 = 'a', 25 = 'z').
k:=0..N-1
-- ASCII code for letter 'a' (a=97 ).
a:=code("a")
-- iterate over k to produce a vector of lower case ASCII character codes
lcCodes[k:=k+a
-- convert vector to string of ordered ASCII lower-case characters.
lcString:=vec2str(lcCodes)
lcString="abcdefghijklmnopqrstuvwxyz"
-- Characters are indexable within the string; for example: substr(lcString,3,1)="d"
Method 2: Using a Function.
-- Mathcad Express lacks the programming capability of Mathcad Prime, so uses the built-in if function to implement a recursive solution (if(predicate,true expr, false expr)).
-- char(cd): return the string character with code cd.
char(cd):=vec2str([cd])
-- charseq(m,n): return a string containing an ordered list of the characters whose codes lie between m and n, inclusive.
charseq(m,n):=if(m>=n,char(m),concat(char(m),charseq(m+1,n)))
charseq(code("a"),code("z"))="abcdefghijklmnopqrstuvwxyz"
charseq(code("A"),code("Z"))="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
charseq(code("0"),code("9"))="0123456789"
charseq(code("а"),code("я"))="абвгдежзийклмнопрстуфхцчшщъыьэюя"
charseq(code("α"),code("ω"))="αβγδεζηθικλμνξοπρςστυφχψω"
Mathematica / Wolfram Language
start = 97;
lowerCaseLetters = Table[FromCharacterCode[start + i], {i, 0, 25}]
- Output:
{"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"}
MATLAB / Octave
'a':'z'
or alternatively
char(96+[1:26])
- Output:
abcdefghijklmnopqrstuvwxyz
Maxima
delete([], makelist(if(alphacharp(ascii(i))) then parse_string(ascii(i)) else [], i, 96, 122));
- Output:
[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]
Mercury
:- module gen_lowercase_ascii.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
:- import_module char, int, list.
main(!IO) :-
list.map(char.det_from_int, 0'a .. 0'z, Alphabet),
io.print_line(Alphabet, !IO).
:- end_module gen_lowercase_ascii.
- Output:
['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']
MiniScript
letters = []
for i in range(code("a"), code("z"))
letters.push char(i)
end for
print letters
- Output:
["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"]
MIPS Assembly
main:
li $t0,'a'
li $t1,26
loop:
jal PrintChar ;prints the low 8 bits of $t0 as an ascii character (unimplemented routine)
nop ;branch delay slot
subiu $t1,1
bne $t1,loop
addiu $t0,1
end_program:
j end_program ;halt the cpu - we're done
nop
MUMPS
Caché
LOWASCMIN
set lowstr = ""
for i = 97:1:122 set delim = $select(i=97:"",1:",") set lowstr = lowstr_delim_$char(i)
write lowstr
quit
- Output:
SAMPLES>DO ^LOWASCMIN 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
Standard MUMPS
LONG SET D=""
FOR X=97:1:122 WRITE D,$C(X) SET D=","
WRITE !
QUIT
;
SHORT S D=""
F X=97:1:122 W D,$C(X) S D=","
W !
Q
- Output:
MGR>DO LONG 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 MGR>D SHORT 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
Nanoquery
lowercase = list()
for i in range(ord("a"), ord("z"))
lowercase.append(chr(i))
end
println lowercase
- Output:
[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]
Neko
/**
<doc>Generate lower case ASCII, in Neko</doc>
**/
var slot = 25
var generated = $smake(slot + 1)
var lower_a = $sget("a", 0)
/* 'a'+25 down to 'a'+0 */
while slot >= 0 {
$sset(generated, slot, slot + lower_a)
slot -= 1
}
$print(generated, "\n")
- Output:
prompt$ nekoc generate-lower.neko prompt$ neko generate-lower.n abcdefghijklmnopqrstuvwxyz
NESL
lower_case_ascii = {code_char(c) : c in [97:123]};
NetLogo
Rationale
Since NetLogo has no "ASC" type reporters, we will have to enumerate the characters. To make an omission easier to detect, we use a phrase, instead of a list Since the phrase has duplicates and spaces, we use other list tools to produce just the sorted alphabet
Code
to-report alphabet-lower
let sample "sphinx of black quartz judge my vow"
let alphabet sort remove-duplicates remove " " n-values length sample [ c -> item c sample ]
if length alphabet != 26 [ user-message "ERROR: invalid sample for alphabet function" ]
report alphabet
end
Output
observer> print alphabet-lower [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] observer> write alphabet-lower ["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"]
Nim
# A slice just contains the first and last value
let alpha: Slice[char] = 'a'..'z'
echo alpha # (a: a, b: z)
# but can be used to check if a character is in it:
echo 'f' in alpha # true
echo 'G' in alpha # false
# A set contains all elements as a bitvector:
let alphaSet: set[char] = {'a'..'z'}
echo alphaSet # {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}
echo 'f' in alphaSet # true
var someChars = {'a','f','g'}
echo someChars <= alphaSet # true
import sequtils
# A sequence:
let alphaSeq = toSeq 'a'..'z'
echo alphaSeq # @[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]
echo alphaSeq[10] # k
Nu
seq char a z
OCaml
# Array.make 26 'a' |> Array.mapi (fun i c -> int_of_char c + i |> char_of_int);;
- : char array =
[|'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'|]
Alternative version:
Array.init 26 (fun x -> char_of_int (x + int_of_char 'a'))
Oforth
Oforth characters are integers. This list is a list of 26 integers
'a' 'z' seqFrom
If necessary, these integers can be added to a string to have a indexed string of chars
StringBuffer new 'a' 'z' seqFrom apply(#<<c)
PARI/GP
Strchr(Vecsmall([97..122]))
Output:
"abcdefghijklmnopqrstuvwxyz"
Pascal
program lowerCaseAscii(input, output, stdErr);
var
alphabet: set of char;
begin
// as per ISO 7185, 'a'..'z' do not necessarily have to be contiguous
alphabet := [
'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'
];
end.
PascalABC.NET
##
var a := Arr('a'..'z');
a.Println;
var s := ('a'..'z').JoinToString(' ');;
s.Println
- Output:
abcdefghijklmnopqrstuvwxyz 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
Perl
print 'a'..'z'
Phix
with javascript_semantics string az = "" for ch='a' to 'z' do az &= ch end for ?az ?tagset('z','a') ?tagstart('a',26)
Using tagset() is obviously easier, but you have to remember its parameters are (finish,start=1,step=1), that way round so that start can be omitted and default to 1 (ditto step). tagstart() wants a length, though you could use 'z'-'a'+1 in place of the 26.
In Phix there is really not much difference between 1..26 and 'a'..'z', and none at all between 'a'..'z' and 97..122.
- Output:
"abcdefghijklmnopqrstuvwxyz" "abcdefghijklmnopqrstuvwxyz" "abcdefghijklmnopqrstuvwxyz"
Phixmonti
0 tolist
'a' 'z' 2 tolist
for
tochar 0 put
endfor
print
Simplest
include ..\Utilitys.pmt
( 'a' 'z' ) for tochar print endfor
PHP
<?php
$lower = range('a', 'z');
var_dump($lower);
?>
Picat
main =>
Alpha1 = (0'a..0'z).map(chr),
println(Alpha1),
Alpha2 = [chr(I) : I in 97..122],
println(Alpha2).
- Output:
abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz
PicoLisp
(mapcar char (range (char "a") (char "z")))
PL/I
gen: procedure options (main); /* 7 April 2014. */
declare 1 ascii union,
2 letters (26) character (1),
2 iletters(26) unsigned fixed binary (8),
letter character(1);
declare i fixed binary;
letters(1), letter = lowercase('A');
do i = 2 to 26;
iletters(i) = iletters(i-1) + 1;
end;
put edit (letters) (a);
end gen;
Output:
abcdefghijklmnopqrstuvwxyz
Alternative, using library:
/* Accessing library lower-case ASCII (PC only). */
letter = lowercase('A');
i = index(collate(), letter);
put skip list (substr(collate, i, 26));
Output:
abcdefghijklmnopqrstuvwxyz
PL/M
100H: /* PRINT THE LOWERCASE LETTERS */
/* CP/M BDOS SYSTEM CALL */
BDOS: PROCEDURE( FN, ARG ); DECLARE FN BYTE, ARG ADDRESS; GOTO 5;END;
/* CONSOLE OUTPUT ROUTINES */
PR$STRING: PROCEDURE( S ); DECLARE S ADDRESS; CALL BDOS( 9, S ); END;
/* TASK */
DECLARE C BYTE, LC ( 27 )BYTE;
DO C = 0 TO 25;
LC( C ) = C + 32 + 'A';
END;
LC( LAST( LC ) ) = '$'; /* STRING TERMINATOR */
CALL PR$STRING( .LC );
EOF
- Output:
abcdefghijklmnopqrstuvwxyz
PL/SQL
Declare
sbAlphabet varchar2(100);
Begin
For nuI in 97..122 loop
if sbAlphabet is null then
sbAlphabet:=chr(nuI);
Else
sbAlphabet:=sbAlphabet||','||chr(nuI);
End if;
End loop;
Dbms_Output.Put_Line(sbAlphabet);
End;
Output:
PL/SQL block, executed in 0 ms 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 Total execution time 16 ms
Plain English
To run:
Start up.
Generate the lowercase ASCII alphabet giving a string.
Write the string on the console.
Wait for the escape key.
Shut down.
To generate the lowercase ASCII alphabet giving a string:
Put the little-a byte into a letter.
Loop.
Append the letter to the string.
If the letter is the little-z byte, exit.
Add 1 to the letter.
Repeat.
- Output:
abcdefghijklmnopqrstuvwxyz
PowerShell
$asString = 97..122 | ForEach-Object -Begin {$asArray = @()} -Process {$asArray += [char]$_} -End {$asArray -join('')}
$asString
- Output:
abcdefghijklmnopqrstuvwxyz
$asArray
- Output:
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
Alternative:
-join [Char[]] (97..122)
- Output:
abcdefghijklmnopqrstuvwxyz
Alternative as of PowerShell-v6.0.0rc:
-join ('a'..'z')
- Output:
abcdefghijklmnopqrstuvwxyz
Prolog
Works with SWI-Prolog 6.5.3
a_to_z(From, To, L) :-
maplist(atom_codes, [From, To], [[C_From], [C_To]]),
bagof([C], between(C_From, C_To, C), L1),
maplist(atom_codes,L, L1).
Output :
?- a_to_z(a, z, L). L = [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].
Python
# From the standard library:
from string import ascii_lowercase
# Generation:
lower = [chr(i) for i in range(ord('a'), ord('z') + 1)]
Or, as a particular instance of a more general enumeration pattern:
'''Enumeration a-z'''
from inspect import signature
import enum
# TEST ----------------------------------------------------
def main():
'''Testing particular instances of a general pattern:
'''
print(
fTable(__doc__ + ':\n')(repr)(showList)(
uncurry(enumFromTo)
)([
('a', 'z'),
('α', 'ω'),
('א', 'ת'),
(1, 10),
(round((5**(1 / 2) - 1) / 2, 5), 5),
('🌱', '🍂')
])
)
# GENERIC -------------------------------------------------
# enumFromTo :: Enum a => a -> a -> [a]
def enumFromTo(m):
'''Enumeration of values [m..n]'''
def go(x, y):
t = type(m)
i = fromEnum(x)
d = 0 if t != float else (x - i)
return list(map(
lambda x: toEnum(t)(d + x),
range(i, 1 + fromEnum(y))
) if int != t else range(x, 1 + y))
return lambda n: go(m, n)
# fromEnum :: Enum a => a -> Int
def fromEnum(x):
'''Index integer for enumerable value.'''
Enum = enum.Enum
return ord(x) if isinstance(x, str) else (
x.value if isinstance(x, Enum) else int(x)
)
# toEnum :: Type -> Int -> a
def toEnum(t):
'''Enumerable value from index integer'''
dct = {
int: int,
float: float,
str: chr,
bool: bool
}
return lambda x: dct[t](x) if t in dct else t(x)
# uncurry :: (a -> b -> c) -> ((a, b) -> c)
def uncurry(f):
'''A function over a tuple, derived from
a vanilla or curried function.
'''
if 1 < len(signature(f).parameters):
return lambda xy: f(*xy)
else:
return lambda xy: f(xy[0])(xy[1])
# FORMATTING -------------------------------------------------
# fTable :: String -> (a -> String) ->
# (b -> String) -> (a -> b) -> [a] -> String
def fTable(s):
'''Heading -> x display function -> fx display function ->
f -> xs -> tabular string.
'''
def go(xShow, fxShow, f, xs):
ys = [xShow(x) for x in xs]
w = max(map(len, ys))
return s + '\n' + '\n'.join(map(
lambda x, y: y.rjust(w, ' ') + ' -> ' + fxShow(f(x)),
xs, ys
))
return lambda xShow: lambda fxShow: lambda f: lambda xs: go(
xShow, fxShow, f, xs
)
# showList :: [a] -> String
def showList(xs):
'''Stringification of a list.'''
return '[' + ','.join(str(x) for x in xs) + ']'
# MAIN ---
if __name__ == '__main__':
main()
- Output:
Enumeration a-z: ('a', '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] ('α', 'ω') -> [α,β,γ,δ,ε,ζ,η,θ,ι,κ,λ,μ,ν,ξ,ο,π,ρ,ς,σ,τ,υ,φ,χ,ψ,ω] ('א', 'ת') -> [א,ב,ג,ד,ה,ו,ז,ח,ט,י,ך,כ,ל,ם,מ,ן,נ,ס,ע,ף,פ,ץ,צ,ק,ר,ש,ת] (1, 10) -> [1,2,3,4,5,6,7,8,9,10] (0.61803, 5) -> [0.61803,1.61803,2.61803,3.61803,4.61803,5.61803] ('🌱', '🍂') -> [🌱,🌲,🌳,🌴,🌵,🌶,🌷,🌸,🌹,🌺,🌻,🌼,🌽,🌾,🌿,🍀,🍁,🍂]
Quackery
The word constant causes the preceding nest to be evaluated during compilation so alpha$ is a literal, not an expression computed during program evaluation.
[ [] 26 times [ i^ char a + join ] ] constant is alpha$ ( --> $ )
alpha$ echo$
- Output:
abcdefghijklmnopqrstuvwxyz
R
# From constants built into R:
letters
# Or generate the same with:
sapply(97:122, intToUtf8)
Racket
(define lowercase-letters (build-list 26 (lambda (x) (integer->char (+ x (char->integer #\a))))))
Raku
(formerly Perl 6)
say my @letters = 'a'..'z';
'a'..'z'
is a range literal, it constructs an immutableRange
object.- Assigning to an
@
variable flattens it into anArray
.
REXX
ASCII version
This version only works under ASCII machines (where the values of the lowercase a through the lowercase z characters are contiguous (and consecutive).
/* REXX ---------------------------------------------------------------
* 08.02.2014 Walter Pachl
*--------------------------------------------------------------------*/
say xrange('a','z')
Output:
abcdefghijklmnopqrstuvwxyz
idiomatic version
This REXX version shows how to generate an indexable string of a similar sequence as per the
lowercase ASCII alphabet (or rather, the Latin [English] alphabet), using a reliable style of coding
(for both ASCII and EBCDIC systems).
This version also works on non-ASCII systems (such as EBCDIC) and isn't dependent on the
consecutiveness nature of any particular ASCII character subsequence.
Note that on an EBCDIC system, there are 41 characters between (lowercase) a ──► z
(inclusive), some of which don't have viewable/displayable glyphs.
/*REXX program creates an indexable string of lowercase ASCII or EBCDIC characters: a─►z*/
$= /*set lowercase letters list to null. */
do j=0 for 2**8; _=d2c(j) /*convert decimal J to a character. */
if datatype(_, 'L') then $=$ || _ /*Is lowercase? Then add it to $ list.*/
end /*j*/ /* [↑] add lowercase letters ──► $ */
say $ /*stick a fork in it, we're all done. */
output
abcdefghijklmnopqrstuvwxyz
Ring
for i in 'a':'z'
put i
next
RPL
≪ "" "a" NUM "z" NUM FOR ascii ascii CHR + NEXT ≫ EVAL
- Output:
1: "abcdefghijklmnopqrstuvwxyz"
Ruby
p ('a' .. 'z').to_a
p [*'a' .. 'z']
Rust
fn main() {
// An iterator over the lowercase alpha's
let ascii_iter = (0..26)
.map(|x| (x + b'a') as char);
println!("{:?}", ascii_iter.collect::<Vec<char>>());
}
- Output:
['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']
S-lang
Char_Type is just an integer-type so a "range array" can be easily created:
variable alpha_ch = ['a':'z'], a;
If you need single-char strings, convert thusly:
variable alpha_st = array_map(String_Type, &char, alpha_ch);
Let's take a peek:
print(alpha_st[23]);
foreach a (alpha_ch)
() = printf("%c ", a);
- Output:
"x" 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
Scala
object Abc extends App {
val lowAlpha = 'a' to 'z' //That's all
// Now several tests
assert(lowAlpha.toSeq == Seq('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'),
"No complete lowercase alphabet.")
assert(lowAlpha.size == 26, "No 26 characters in alphabet")
assert(lowAlpha.start == 'a', "Character 'a' not first char! ???")
assert(lowAlpha.head == 'a', "Character 'a' not heading! ???")
assert(lowAlpha.head == lowAlpha(0), "Heading char is not first char.")
assert(lowAlpha contains 'n', "Character n not present.")
assert(lowAlpha.indexOf('n') == 13, "Character n not on the 14th position.")
assert(lowAlpha.last == lowAlpha(25), "Expected character (z)on the last and 26th pos.")
println(s"Successfully completed without errors. [within ${
scala.compat.Platform.currentTime - executionStart
} ms]")
}
- Output:
Successfully completed without errors. [within 675 ms] Process finished with exit code 0
Scheme
(map integer->char (iota 26 (char->integer #\a)))
- Output:
(#\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)
Seed7
$ include "seed7_05.s7i";
const proc: main is func
local
var string: lower is "";
var char: ch is ' ';
begin
for ch range 'a' to 'z' do
lower &:= ch;
end for;
writeln(lower);
end func;
- Output:
abcdefghijklmnopqrstuvwxyz
Sidef
var arr = 'a'..'z';
say arr.join(' ');
Smalltalk
| asciiLower |
asciiLower := String new.
97 to: 122 do: [:asciiCode |
asciiLower := asciiLower , asciiCode asCharacter
].
^asciiLower
Snobol
&ALPHABET ('a' LEN(25)) . OUTPUT ;* Works in ASCII but not EBCDIC.
SPL
> i, 1..26
d = [i+96,0]
a[i] = #.str(d)
<
'now A is an array of letters a..z
> i, 1..#.size(a,1)
#.output(a[i],#.rs)
<
- Output:
abcdefghijklmnopqrstuvwxyz
Standard ML
val lowercase_letters = List.tabulate (26, fn x => chr (x + ord #"a"));
Stata
// built-in: lowercase and uppercase letters
display c(alpha)
display c(ALPHA)
// generate a variable with the letters
clear
set obs 26
gen a=char(96+_n)
// or in Mata
mata
char(97..122)
end
SuperCollider
Previously, it was claimed that the method that maps ascii number to character is polymorphic on collections. However, that doesn't seem to be the case – at least not anymore in the newer version (3.10.2). A fix was added below the original code.
(97..122).asAscii; // This example unfortunately throws an error
// for me when running it on version 3.10.2
// Apparently, the message 'asAscii' cannot be understood by
// an Array, so I used the message 'collect' to apply the function
// enclosed in {} to each individual element of the Array,
// passing them the message 'asAscii':
(97..122).collect({|asciiCode| asciiCode.asAscii});
// Instead of writing the ascii codes directly as numbers,
// one could also pass the chars a and z the message 'ascii' to convert
// them to ascii codes – perhaps making the code a bit clearer:
($a.ascii..$z.ascii).collect({|asciiCode| asciiCode.asAscii});
// both examples output [ 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 ]
Backwards:
"abcdefghijklmnopqrstuvwxyz".ascii
// answers [ 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122 ]
Swift
var letters = [Character]()
for i in 97...122 {
let char = Character(UnicodeScalar(i))
letters.append(char)
}
Tcl
The most common way of doing this in Tcl would be to use a simple literal; it's only 51 characters after all:
set alpha {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}
Though it could be done like this as well:
set alpha [apply {{} {
scan "az" "%c%c" from to
for {set i $from} {$i <= $to} {incr i} {
lappend l [format "%c" $i]
}
return $l
}}]
UNIX Shell
In bash or ksh93 with braceexpand set:
lower=({a..z})
In zsh with braceccl set:
lower=({a-z})
Either way, you can display the result like this:
echo "${lower[@]}"
- Output:
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
Ursa
Creates a string named low containing the lower case ASCII alphabet.
decl int i
decl string low
for (set i (ord "a")) (< i (+ (ord "z") 1)) (inc i)
set low (+ low (chr i))
end for
out low endl console
VBA
Option Explicit
Sub Main_Lower_Case_Ascii_Alphabet()
Dim Alpha() As String
Alpha = Alphabet(97, 122)
Debug.Print Join(Alpha, ", ")
End Sub
Function Alphabet(FirstAscii As Byte, LastAscii As Byte) As String()
Dim strarrTemp() As String, i&
ReDim strarrTemp(0 To LastAscii - FirstAscii)
For i = FirstAscii To LastAscii
strarrTemp(i - FirstAscii) = Chr(i)
Next
Alphabet = strarrTemp
Erase strarrTemp
End Function
- Output:
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
VBScript
Function ASCII_Sequence(range)
arr = Split(range,"..")
For i = Asc(arr(0)) To Asc(arr(1))
ASCII_Sequence = ASCII_Sequence & Chr(i) & " "
Next
End Function
WScript.StdOut.Write ASCII_Sequence(WScript.Arguments(0))
WScript.StdOut.WriteLine
- Output:
C:\>cscript /nologo ascii_sequence.vbs a..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 C:\>cscript /nologo ascii_sequence.vbs A..F A B C D E F
Verilog
module main;
integer i;
initial begin
for(i = 97; i <= 122; i=i+1)
begin
$write("%c ",i);
end
$finish ;
end
endmodule
- Output:
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
Vim Script
let lower = []
for c in range(0, 25)
let lower += [nr2char(c + char2nr("a"))]
endfor
or:
echo map(range(char2nr('a'), char2nr('z')), 'nr2char(v:val)')
Visual Basic
The #VBA example works in VB6 as well, without any change.
Visual Basic .NET
Used Asc(Char) [returns Integer value of Char passed] and Chr(Integer) [returns Char value of Integer passed] functions.
String.Join() is used to print the list, converted to array, without looping through it.
Module LowerASCII
Sub Main()
Dim alphabets As New List(Of Char)
For i As Integer = Asc("a") To Asc("z")
alphabets.Add(Chr(i))
Next
Console.WriteLine(String.Join("", alphabets.ToArray))
End Sub
End Module
- Output:
abcdefghijklmnopqrstuvwxyz
V (Vlang)
fn loweralpha() string {
mut p := []u8{len: 26}
for i in 97..123 {
p[i-97] = u8(i)
}
return p.bytestr()
}
WebAssembly
(module $lowercase
(import "wasi_unstable" "fd_write"
(func $fd_write (param i32 i32 i32 i32) (result i32))
)
(memory 1)
(export "memory" (memory 0))
(func $main (export "_start")
(local $i i32)
(i32.store (i32.const 0) (i32.const 8)) ;; offset to start of string
(i32.store (i32.const 4) (i32.const 27)) ;; string length
(set_local $i (i32.const 0))
(loop
;; mem[i+8] = i+97
(i32.store (i32.add (get_local $i) (i32.const 8)) (i32.add (get_local $i) (i32.const 97)))
;; i = i+1
(set_local $i (i32.add (get_local $i) (i32.const 1)))
;; if i < 26 then loop
(br_if 0 (i32.lt_s (get_local $i) (i32.const 26)))
)
;; append a newline
(i32.store (i32.add (get_local $i) (i32.const 8)) (i32.const 10))
;; write to stdout
(call $fd_write
(i32.const 1) ;; output stream to write to (1 == stdout)
(i32.const 0) ;; memory location containing string offset and length
(i32.const 1) ;; number of strings to write
(i32.const 40) ;; location in memory to write number of bytes written
)
drop
)
)
- Output:
abcdefghijklmnopqrstuvwxyz
Wren
var alpha = []
for (c in 97..122) alpha.add(String.fromByte(c))
System.print(alpha.join())
- Output:
abcdefghijklmnopqrstuvwxyz
xEec
h$` h$` >0_0 t h$y ms p h? jn00_0 p r h#1 ma t jn0_0 >00_0 p p r p
XLISP
(defun ascii-lower ()
(defun add-chars (x y s)
(if (<= x y)
(add-chars (+ x 1) y (string-append s (string (integer->char x))))
s))
(add-chars 97 122 ""))
XPL0
char I, A(26);
for I:= 0 to 26-1 do A(I):= I+^a
Z80 Assembly
org &8000
ld a,'a' ;data
ld b,26 ;loop counter
ld hl,Alphabet ;destination
loop:
ld (hl),a ;store "a" into ram
inc a ;next letter
inc hl ;next storage byte
djnz loop ;repeat until 26 letters were stored.
call Monitor_MemDump ;hexdumps the specified address and bytecount to screen - created by Keith S. of Chibiakumas
byte 32 ;number of bytes to display
word Alphabet ;address to dump from
ret ;return to basic
Alphabet:
ds 26,0 ;reserve 26 bytes of ram, init all to zero.
- Output:
8013: 61 62 63 64 65 66 67 68 abcdefgh 69 6A 6B 6C 6D 6E 6F 70 ijklmnop 71 72 73 74 75 76 77 78 qrstuvwx 79 7A 00 00 00 00 00 00 yz
zkl
["a".."z"] // lasy list
["a".."z"].walk() //-->L("a","b","c","d","e",...
"a".toAsc().pump(26,List,"toChar") // another way to create the list
"a".toAsc().pump(26,String,"toChar") // create a string
//-->"abcdefghijklmnopqrstuvwxyz"
Utils.Helpers.lowerLetters // string const
Zig
const std = @import("std");
pub fn main() !void {
const cnt_lower = 26;
var lower: [cnt_lower]u8 = undefined;
comptime var i = 0;
inline while (i < cnt_lower) : (i += 1)
lower[i] = i + 'a';
const stdout_wr = std.io.getStdOut().writer();
for (lower) |l|
try stdout_wr.print("{c} ", .{l});
try stdout_wr.writeByte('\n');
}
- Programming Tasks
- String manipulation
- 0815
- 11l
- 360 Assembly
- 6502 Assembly
- 68000 Assembly
- 8080 Assembly
- 8086 Assembly
- 8th
- ABAP
- Action!
- Ada
- ALGOL 68
- ALGOL W
- APL
- AppleScript
- Applesoft BASIC
- ARM Assembly
- Arturo
- ATS
- AutoHotkey
- AutoIt
- AWK
- BASIC
- BBC BASIC
- BASIC256
- Commodore BASIC
- FreeBASIC
- IS-BASIC
- PureBasic
- QBasic
- True BASIC
- XBasic
- Yabasic
- Run BASIC
- UBasic/4tH
- ZX Spectrum Basic
- BaCon
- Batch File
- Befunge
- BQN
- Bracmat
- Brainf***
- Burlesque
- C
- C sharp
- C++
- Clojure
- CLU
- COBOL
- CoffeeScript
- Comal
- Common Lisp
- Cowgol
- D
- Dc
- Delphi
- Draco
- DUP
- Dyalect
- EasyLang
- EchoLisp
- Elena
- Elixir
- Erlang
- Excel
- F Sharp
- Factor
- FALSE
- Fermat
- Forth
- Fortran
- Free Pascal
- Frink
- Furor
- Peri
- FutureBasic
- Gambas
- Go
- Groovy
- Haskell
- Hoon
- Huginn
- Icon
- Unicon
- Insitux
- J
- Java
- JavaScript
- Joy
- Jq
- Jsish
- Julia
- K
- Keg
- Kotlin
- Lambdatalk
- Lang
- LC3 Assembly
- Lingo
- Logo
- Lua
- M2000 Interpreter
- Maple
- Mathcad
- None
- Mathematica
- Wolfram Language
- MATLAB
- Octave
- Maxima
- Mercury
- MiniScript
- MIPS Assembly
- MUMPS
- Nanoquery
- Neko
- NESL
- NetLogo
- Nim
- Nu
- OCaml
- Oforth
- PARI/GP
- Pascal
- PascalABC.NET
- Perl
- Phix
- Phixmonti
- PHP
- Picat
- PicoLisp
- PL/I
- PL/M
- PL/SQL
- Plain English
- PowerShell
- Prolog
- Python
- Quackery
- R
- Racket
- Raku
- REXX
- Ring
- RPL
- Ruby
- Rust
- S-lang
- Scala
- Scheme
- Seed7
- Sidef
- Smalltalk
- Snobol
- SPL
- Standard ML
- Stata
- SuperCollider
- Swift
- Tcl
- UNIX Shell
- Ursa
- VBA
- VBScript
- Verilog
- Vim Script
- Visual Basic
- Visual Basic .NET
- V (Vlang)
- WebAssembly
- Wren
- XEec
- XLISP
- XPL0
- Z80 Assembly
- Zkl
- Zig
- Pages with too many expensive parser function calls