June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -0,0 +1,3 @@
REPORT lower_case_ascii.
WRITE: / to_lower( sy-abcde ).

View file

@ -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( ).

View file

@ -1 +0,0 @@
DATA(alpha) = to_lower( sy-abcde ).

View file

@ -5,56 +5,34 @@ on run
end run
-- GENERIC FUNCTIONS ----------------------------------------------------------
-- chr :: Int -> Char
on chr(n)
character id n
end chr
-- ord :: Char -> Int
on ord(c)
id of c
end ord
-- GENERIC FUNCTIONS ---------------------------------------------------------
-- enumFromTo :: Enum a => a -> a -> [a]
on enumFromTo(m, n)
set {intM, intN} to {fromEnum(m), fromEnum(n)}
if intM > intN then
set d to -1
if class of m is integer then
enumFromToInt(m, n)
else
set d to 1
enumFromToChar(m, n)
end if
set lst to {}
if class of m is text then
repeat with i from intM to intN by d
set end of lst to chr(i)
end repeat
else
repeat with i from intM to intN by d
set end of lst to i
end repeat
end if
return lst
end enumFromTo
-- fromEnum :: Enum a => a -> Int
on fromEnum(x)
set c to class of x
if c is boolean then
if x then
1
else
0
end if
else if c is text then
if x "" then
id of x
else
missing value
end if
-- 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
-- signum :: Num -> Num
on signum(x)
if x < 0 then
-1
else if x = 0 then
0
else
x as integer
1
end if
end fromEnum
end signum

View file

@ -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

View file

@ -0,0 +1,3 @@
>>>>>>>>>>>>>>>>>>>>>>>>>>>>++++++++++++++++++++++++++[-<<[+<]
+[>]>]<<[+++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++<]>[.>]++++++++++.

View file

@ -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)));
}
}

View file

@ -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}

View file

@ -0,0 +1,34 @@
import extensions.
import system'collections.
singleton Alphabet :: BaseEnumerable
{
enumerator = Enumerator::
{
char current.
get = current.
bool next
[
if ($nil==current)
[
current := $97.
];
if (current != $122)
[
current := (current toInt + 1) toChar.
];
[
^ false
].
^ true
]
}.
}
program =
[
console printLine(Alphabet).
].

View file

@ -1,5 +1,2 @@
['a':'z']
[c for c = 'a':'z']
string('a':'z'...)
@show collect('a':'z')
@show join('a':'z')

View file

@ -0,0 +1,4 @@
# 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'|]

View file

@ -1 +1 @@
my @letters = 'a'..'z';
say my @letters = 'a'..'z';

View file

@ -0,0 +1,19 @@
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