Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
3
Task/Generate-lower-case-ASCII-alphabet/00-META.yaml
Normal file
3
Task/Generate-lower-case-ASCII-alphabet/00-META.yaml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
from: http://rosettacode.org/wiki/Generate_lower_case_ASCII_alphabet
|
||||
note: String_manipulation
|
||||
12
Task/Generate-lower-case-ASCII-alphabet/00-TASK.txt
Normal file
12
Task/Generate-lower-case-ASCII-alphabet/00-TASK.txt
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
;Task:
|
||||
Generate an array, list, lazy sequence, or even an indexable string of all the lower case ASCII characters, from <big> a </big> to <big> z.</big> 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:
|
||||
<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>
|
||||
|
||||
|
||||
{{Template:Strings}}
|
||||
<br><br>
|
||||
|
||||
|
|
@ -0,0 +1 @@
|
|||
<:61:~}:000:>>&{~<:7a:-#:001:<:1:+^:000:
|
||||
|
|
@ -0,0 +1 @@
|
|||
print(Array(‘a’..‘z’))
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
* 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
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
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
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
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
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
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
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
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
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
"" ( 'a n:+ s:+ ) 0 25 loop
|
||||
. cr
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
REPORT lower_case_ascii.
|
||||
|
||||
WRITE: / to_lower( sy-abcde ).
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
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( ).
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
# 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"
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
# 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
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
% set lc to the lower case alphabet %
|
||||
string(26) lc;
|
||||
for c := 0 until 25 do lc( c // 1 ) := code( decode( "a" ) + c );
|
||||
|
|
@ -0,0 +1 @@
|
|||
⎕UCS 96+⍳26
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
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
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
(* ****** ****** *)
|
||||
//
|
||||
// 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] *)
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# 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)
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
byte X
|
||||
|
||||
Proc Main()
|
||||
|
||||
For X=97 To 122
|
||||
Do
|
||||
Put(x)
|
||||
Od
|
||||
|
||||
Return
|
||||
|
|
@ -0,0 +1 @@
|
|||
type Lower_Case is new Character range 'a' .. 'z';
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
type Arr_Type is array (Integer range <>) of Lower_Case;
|
||||
A : Arr_Type (1 .. 26) := "abcdefghijklmnopqrstuvwxyz";
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
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
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
-------------------- 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
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
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
|
||||
|
|
@ -0,0 +1 @@
|
|||
{"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"}
|
||||
|
|
@ -0,0 +1 @@
|
|||
L$="abcdefghijklmnopqrstuvwxyz"
|
||||
|
|
@ -0,0 +1 @@
|
|||
L$="":FORI=1TO26:L$=L$+CHR$(96+I):NEXT
|
||||
|
|
@ -0,0 +1 @@
|
|||
print to [:char] 97..122
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
a :={}
|
||||
Loop, 26
|
||||
a.Insert(Chr(A_Index + 96))
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
Func _a2z()
|
||||
Local $a2z = ""
|
||||
For $i = 97 To 122
|
||||
$a2z &= Chr($i)
|
||||
Next
|
||||
Return $a2z
|
||||
EndFunc
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
# 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
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
DIM lower&(25)
|
||||
FOR i%=0TO25
|
||||
lower&(i%)=ASC"a"+i%
|
||||
NEXT
|
||||
END
|
||||
|
|
@ -0,0 +1 @@
|
|||
'a'+↕26
|
||||
|
|
@ -0,0 +1 @@
|
|||
PRINT LOOP$(26, CHR$(96+_))
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
@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
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
0"z":>"a"`#v_ >:#,_$@
|
||||
^:- 1:<
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
a:?seq:?c
|
||||
& whl
|
||||
' ( chr$(asc$!c+1):~>z:?c
|
||||
& !seq !c:?seq
|
||||
)
|
||||
& !seq
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
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
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
>>>>>>>>>>>>>>>>>>>>>>>>>>>>++++++++++++++++++++++++++[-<<[+<]
|
||||
+[>]>]<<[+++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
+++++++++++++++++++++++++++++++++++++++++++<]>[.>]++++++++++.
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
++++++++++++++++++++++++++ >
|
||||
++++++++++++++++++++++++++ ++++++
|
||||
++++++++++++++++++++++++++ ++++++
|
||||
++++++++++++++++++++++++++ ++++++
|
||||
< [ - > + . < ]
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
blsq ) @azr\sh
|
||||
abcdefghijklmnopqrstuvwxyz
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
#include <string>
|
||||
#include <numeric>
|
||||
|
||||
int main() {
|
||||
std::string lower(26,' ');
|
||||
|
||||
std::iota(lower.begin(), lower.end(), 'a');
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
|
||||
internal class Program
|
||||
{
|
||||
private static void Main()
|
||||
{
|
||||
Console.WriteLine(String.Concat(Enumerable.Range('a', 26).Select(c => (char)c)));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
#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;
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
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
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
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).
|
||||
|
|
@ -0,0 +1 @@
|
|||
(map char (range (int \a) (inc (int \z))))
|
||||
|
|
@ -0,0 +1 @@
|
|||
(String.fromCharCode(x) for x in [97..122])
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
dim alphabet$ of 26
|
||||
for i := 1 to 26
|
||||
alphabet$(i) := chr$(ord("a") - 1 + i)
|
||||
endfor i
|
||||
print alphabet$
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
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$
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
(defvar *lower*
|
||||
(loop with a = (char-code #\a)
|
||||
for i below 26
|
||||
collect (code-char (+ a i))))
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
(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.")
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
(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)))
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
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]));
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
import std.ascii: lowercase;
|
||||
|
||||
void main() {}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
void main() {
|
||||
char['z' - 'a' + 1] arr;
|
||||
|
||||
foreach (immutable i, ref c; arr)
|
||||
c = 'a' + i;
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
void main() {
|
||||
import std.range, std.algorithm, std.array;
|
||||
|
||||
char[26] arr = 26.iota.map!(i => cast(char)('a' + i)).array;
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
void main() {
|
||||
char[] arr;
|
||||
|
||||
foreach (immutable char c; 'a' .. 'z' + 1)
|
||||
arr ~= c;
|
||||
|
||||
assert(arr == "abcdefghijklmnopqrstuvwxyz");
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
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}
|
||||
|
|
@ -0,0 +1 @@
|
|||
122 [ d 1 - d 97<L 256 * + ] d sL x P
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
program atoz;
|
||||
|
||||
var
|
||||
ch : char;
|
||||
|
||||
begin
|
||||
for ch in ['a'..'z'] do
|
||||
begin
|
||||
write(ch);
|
||||
end;
|
||||
end.
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
/* 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
|
||||
|
|
@ -0,0 +1 @@
|
|||
print << ('a'..'z').ToArray()
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
for i = 97 to 122
|
||||
alphabet$[] &= strchar i
|
||||
.
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
for i = 97 to 122
|
||||
alphabet$ &= strchar i
|
||||
.
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
;; 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
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
import extensions;
|
||||
import system'collections;
|
||||
|
||||
singleton Alphabet : Enumerable
|
||||
{
|
||||
Enumerator enumerator() = new Enumerator
|
||||
{
|
||||
char current;
|
||||
|
||||
get() = 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)
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
iex(1)> Enum.to_list(?a .. ?z)
|
||||
'abcdefghijklmnopqrstuvwxyz'
|
||||
iex(2)> Enum.to_list(?a .. ?z) |> List.to_string
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
|
|
@ -0,0 +1 @@
|
|||
lists:seq($a,$z).
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
showAlphabet
|
||||
=LAMBDA(az,
|
||||
ENUMFROMTOCHAR(
|
||||
MID(az, 1, 1)
|
||||
)(
|
||||
MID(az, 2, 1)
|
||||
)
|
||||
)
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
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
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
let lower = ['a'..'z']
|
||||
|
||||
printfn "%A" lower
|
||||
|
|
@ -0,0 +1 @@
|
|||
'a[$'z>~][$,1+]#%
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
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
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
Array locase[1,26];
|
||||
[locase]:=[<i=1,26>'a'+i-1];
|
||||
!([locase:char);
|
||||
|
|
@ -0,0 +1 @@
|
|||
: printit 26 0 do [char] a I + emit loop ;
|
||||
|
|
@ -0,0 +1 @@
|
|||
: printit2 [char] z 1+ [char] a do I emit loop ;
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
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 ;
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
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
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
character(26) :: alpha
|
||||
integer :: i
|
||||
|
||||
do i = 1, 26
|
||||
alpha(i:i) = achar(iachar('a') + i - 1)
|
||||
end do
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
program lowerCaseAscii(input, output, stdErr);
|
||||
const
|
||||
alphabet = ['a'..'z'];
|
||||
begin
|
||||
end.
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
' 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
|
||||
|
|
@ -0,0 +1 @@
|
|||
map["char", char["a"] to char["z"]]
|
||||
|
|
@ -0,0 +1 @@
|
|||
toArray[map["char", char["a"] to char["z"]]]
|
||||
|
|
@ -0,0 +1 @@
|
|||
#k 'a 'z ++ {|| {} print SPACE |} NL end
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
long i
|
||||
for i = asc("a") to asc("z")
|
||||
print chr$(i);
|
||||
next
|
||||
HandleEvents
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
Public Sub Main()
|
||||
Dim siCount As Short
|
||||
|
||||
For siCount = Asc("a") To Asc("z")
|
||||
Print Chr(siCount);
|
||||
Next
|
||||
|
||||
End
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
func loweralpha() string {
|
||||
p := make([]byte, 26)
|
||||
for i := range p {
|
||||
p[i] = 'a' + byte(i)
|
||||
}
|
||||
return string(p)
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
def lower = ('a'..'z')
|
||||
|
|
@ -0,0 +1 @@
|
|||
assert 'abcdefghijklmnopqrstuvwxyz' == lower.join('')
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
lower = ['a' .. 'z']
|
||||
|
||||
main = print lower
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
alpha :: String
|
||||
alpha = enumFromTo 'a' 'z'
|
||||
|
||||
main :: IO ()
|
||||
main = print alpha
|
||||
|
|
@ -0,0 +1 @@
|
|||
`(list cord)`(gulf 97 122)
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
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
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
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$
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
every a := put([], !&lcase) # array of 1 character per element
|
||||
c := create !&lcase # lazy generation of letters in sequence
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
procedure lower_case_letters() # entry point for function lower_case_letters
|
||||
return &lcase # returning lower caser letters represented by the set &lcase
|
||||
end
|
||||
|
||||
procedure main(param) # main procedure as entry point
|
||||
write(lower_case_letters()) # output of result of function lower_case_letters()
|
||||
end
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
thru=: <. + i.@(+*)@-~
|
||||
thru&.(a.&i.)/'az'
|
||||
abcdefghijklmnopqrstuvwxyz
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue