Generate lower case ASCII alphabet: Difference between revisions

m
m (→‎{{header|OCaml}}: alternative)
 
(10 intermediate revisions by 10 users not shown)
Line 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 1,011 ⟶ 1,010:
 
=={{header|Elena}}==
ELENA 56.0x :
<syntaxhighlight lang="elena">import extensions;
import system'collections;
Line 1,021 ⟶ 1,020:
char current;
get Value() = current;
bool next()
Line 1,468 ⟶ 1,467:
</pre>
 
=={{header|Peri}}==
<syntaxhighlight lang="easylangperi">
###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,526 ⟶ 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,572 ⟶ 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,584 ⟶ 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,727 ⟶ 1,765:
א ב ג ד ה ו ז ח ט י ך כ ל ם מ ן נ ס ע ף פ ץ צ ק ר ש ת
🐐 🐑 🐒 🐓 🐔 🐕 🐖 🐗 🐘 🐙 🐚 🐛 🐜 🐝 🐞 🐟</pre>
 
=={{header|Joy}}==
<syntaxhighlight lang="joy">'a ['z =] ["" cons] [dup succ] [cons] linrec.</syntaxhighlight>
 
=={{header|jq}}==
Line 1,825 ⟶ 1,866:
fn.println(&alphabet)
 
# As string (Strings are called text in langLang)
$alphabetText = fn.join(\e, &alphabet)
fn.println($alphabetText)
Line 2,153 ⟶ 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,184 ⟶ 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,954 ⟶ 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