Generate lower case ASCII alphabet: Difference between revisions

m
(Added EasyLang implementation)
m (→‎{{header|OCaml}}: alternative)
 
(14 intermediate revisions by 13 users not shown)
Line 584:
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}}===
Line 960 ⟶ 978:
 
=={{header|EasyLang}}==
Generated on an array:
<syntaxhighlight lang="easylang">
# Generated on an array
for i = 97 to 122
alphabet$[] &= strchar i
.
print alphabet$[]
</syntaxhighlight>
# Generated on a string
 
Generated on a string:
<syntaxhighlight lang="easylang">
for i = 97 to 122
alphabet$ &= strchar i
.
print alphabet$
</syntaxhighlight>
 
Line 993 ⟶ 1,010:
 
=={{header|Elena}}==
ELENA 56.0x :
<syntaxhighlight lang="elena">import extensions;
import system'collections;
Line 1,003 ⟶ 1,020:
char current;
get Value() = current;
bool next()
Line 1,384 ⟶ 1,401:
Two methods are demonstrated below
 
<syntaxhighlight lang="textforth">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+ + ;
 
Line 1,450 ⟶ 1,467:
</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}}==
Line 1,508 ⟶ 1,534:
{{Out}}
<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}}==
Line 1,554 ⟶ 1,588:
end
</syntaxhighlight>
 
=={{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}}==
Line 1,566 ⟶ 1,609:
 
=={{header|Java}}==
<syntaxhighlight lang="java">
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 {
 
Line 1,709 ⟶ 1,765:
א ב ג ד ה ו ז ח ט י ך כ ל ם מ ן נ ס ע ף פ ץ צ ק ר ש ת
🐐 🐑 🐒 🐓 🐔 🐕 🐖 🐗 🐘 🐙 🐚 🐛 🐜 🐝 🐞 🐟</pre>
 
=={{header|Joy}}==
<syntaxhighlight lang="joy">'a ['z =] ["" cons] [dup succ] [cons] linrec.</syntaxhighlight>
 
=={{header|jq}}==
Line 1,801 ⟶ 1,860:
-> 0 1 2 3 4 5 6 7 8 9
</syntaxhighlight>
 
=={{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}}==
Line 2,119 ⟶ 2,194:
[|'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>
 
Alternative version:
<syntaxhighlight lang="ocaml">Array.init 26 (fun x -> char_of_int (x + int_of_char 'a'))</syntaxhighlight>
 
=={{header|Oforth}}==
Line 2,150 ⟶ 2,228:
=={{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: #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: #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>
<!--</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). 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.
{{out}}
<pre>
"abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz"
Line 2,552 ⟶ 2,633:
put i
next</syntaxhighlight>
 
=={{header|RPL}}==
≪ ""
"a" NUM "z" NUM '''FOR''' ascii
ascii CHR + '''NEXT'''
≫ EVAL
{{out}}
<pre>
1: "abcdefghijklmnopqrstuvwxyz"
</pre>
 
=={{header|Ruby}}==
Line 2,910 ⟶ 3,001:
 
=={{header|Wren}}==
<syntaxhighlight lang="javascriptwren">var alpha = []
for (c in 97..122) alpha.add(String.fromByte(c))
System.print(alpha.join())</syntaxhighlight>
23

edits