September Morn Update
This commit is contained in:
parent
4e2d22a71d
commit
aac6731f2c
6856 changed files with 141342 additions and 21127 deletions
|
|
@ -1,18 +1,18 @@
|
|||
import system'collections.
|
||||
import system'routines.
|
||||
import extensions.
|
||||
import system'collections;
|
||||
import system'routines;
|
||||
import extensions;
|
||||
|
||||
public program
|
||||
[
|
||||
public program()
|
||||
{
|
||||
// 1. Create
|
||||
var aMap := Dictionary new.
|
||||
aMap["key"] := "foox".
|
||||
aMap["key"] := "foo".
|
||||
aMap["key2"]:= "foo2".
|
||||
aMap["key3"]:= "foo3".
|
||||
aMap["key4"]:= "foo4".
|
||||
var map := new Dictionary();
|
||||
map["key"] := "foox";
|
||||
map["key"] := "foo";
|
||||
map["key2"]:= "foo2";
|
||||
map["key3"]:= "foo3";
|
||||
map["key4"]:= "foo4";
|
||||
|
||||
// Enumerate
|
||||
aMap forEach
|
||||
(:aKeyValue)[ console printLine(aKeyValue key," : ",aKeyValue value) ].
|
||||
]
|
||||
map.forEach:
|
||||
(keyValue){ console.printLine(keyValue.Key," : ",keyValue.Value) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
import system'collections.
|
||||
import system'routines.
|
||||
import extensions.
|
||||
import system'collections;
|
||||
import system'routines;
|
||||
import extensions;
|
||||
|
||||
public program
|
||||
[
|
||||
public program()
|
||||
{
|
||||
// 1. Create
|
||||
auto aMap := Map<literal,literal>().
|
||||
aMap["key"] := "foox".
|
||||
aMap["key"] := "foo".
|
||||
aMap["key2"]:= "foo2".
|
||||
aMap["key3"]:= "foo3".
|
||||
aMap["key4"]:= "foo4".
|
||||
auto map := new Map<string,string>();
|
||||
map["key"] := "foox";
|
||||
map["key"] := "foo";
|
||||
map["key2"]:= "foo2";
|
||||
map["key3"]:= "foo3";
|
||||
map["key4"]:= "foo4";
|
||||
|
||||
// Enumerate
|
||||
aMap forEach
|
||||
(:tuple)[ console printLine(tuple item1," : ",tuple item2) ].
|
||||
]
|
||||
map.forEach:
|
||||
(tuple){ console.printLine(tuple.Item1," : ",tuple.Item2) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
program AssociativeArrayIteration;
|
||||
{$mode delphi}{$ifdef windows}{$apptype console}{$endif}
|
||||
uses Generics.Collections;
|
||||
|
||||
type
|
||||
TlDictionary = TDictionary<string, Integer>;
|
||||
TlPair = TPair<string,integer>;
|
||||
|
||||
var
|
||||
i: Integer;
|
||||
s: string;
|
||||
lDictionary: TlDictionary;
|
||||
lPair: TlPair;
|
||||
begin
|
||||
lDictionary := TlDictionary.Create;
|
||||
try
|
||||
lDictionary.Add('foo', 5);
|
||||
lDictionary.Add('bar', 10);
|
||||
lDictionary.Add('baz', 15);
|
||||
lDictionary.AddOrSetValue('foo',6);
|
||||
for lPair in lDictionary do
|
||||
Writeln('Pair: ',Lpair.Key,' = ',lPair.Value);
|
||||
for s in lDictionary.Keys do
|
||||
Writeln('Key: ' + s);
|
||||
for i in lDictionary.Values do
|
||||
Writeln('Value: ', i);
|
||||
finally
|
||||
lDictionary.Free;
|
||||
end;
|
||||
end.
|
||||
|
|
@ -5,16 +5,19 @@
|
|||
║ isn't defined, it can be displayed to indicate such, or its value can be checked ║
|
||||
║ to determine if a particular associative array element has been set (defined). ║
|
||||
╚════════════════════════════════════════════════════════════════════════════════════╝*/
|
||||
stateF.= ' [not defined yet] ' /*sets any/all state former capitols.*/
|
||||
stateF.= ' [not defined yet] ' /*sets any/all state former capitals.*/
|
||||
stateN.= ' [not defined yet] ' /*sets any/all state names. */
|
||||
w = 0 /*the maximum length of a state name.*/
|
||||
stateL=
|
||||
stateL =
|
||||
/*╔════════════════════════════════════════════════════════════════════════════════════╗
|
||||
║ The list of states (empty now). It's convenient to have them in alphabetic order; ║
|
||||
║ they'll be listed in this order. In REXX, when a key is used, it's normally ║
|
||||
║ stored (internally) as as uppercase characters (as in the examples below). ║
|
||||
║ Actually, any characters can be used, including blank(s) and non─displayable ║
|
||||
║ characters (including '00'x, 'ff'x, commas, periods, quotes, ···). ║
|
||||
║ The list of states (empty as of now). It's convenient to have them in alphabetic ║
|
||||
║ order; they'll be listed in the order as they are in the REXX program below). ║
|
||||
║ In REXX, when a key is used (for a stemmed array, as they are called in REXX), ║
|
||||
║ and the key isn't assigned a value, the key's name is stored (internally) as ║
|
||||
║ uppercase (Latin) characters (as in the examples below. If the key has a ║
|
||||
║ a value, the key's value is used as is (i.e.: no upper translation is performed).║
|
||||
║ Actually, any characters can be used, including blank(s) and non─displayable ║
|
||||
║ characters (including '00'x, 'ff'x, commas, periods, quotes, ···). ║
|
||||
╚════════════════════════════════════════════════════════════════════════════════════╝*/
|
||||
call setSC 'al', "Alabama" , 'Tuscaloosa'
|
||||
call setSC 'ca', "California" , 'Benicia'
|
||||
|
|
@ -42,14 +45,14 @@ call setSC 'sc', "South Carolina" , 'Charlestown'
|
|||
call setSC 'tn', "Tennessee" , 'Murfreesboro'
|
||||
call setSC 'vt', "Vermont" , 'Windsor'
|
||||
|
||||
do j=1 for words(stateL) /*show all capitols that were defined. */
|
||||
q=word(stateL, j) /*get the next (USA) state in the list.*/
|
||||
say 'the former capitol of ('q") " left(stateN.q, w) " was " stateC.q
|
||||
do j=1 for words(stateL) /*show all capitals that were defined. */
|
||||
$= word(stateL, j) /*get the next (USA) state in the list.*/
|
||||
say 'the former capital of ('$") " left(stateN.$, w) " was " stateC.$
|
||||
end /*j*/ /* [↑] show states that were defined.*/
|
||||
exit /*stick a fork in it, we're all done. */
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
setSC: parse arg code,name,cap; upper code /*get code, name & cap.; uppercase code*/
|
||||
stateL=stateL code /*keep a list of all the US state codes*/
|
||||
stateN.code=name; w=max(w,length(name)) /*define the state's name; max width. */
|
||||
stateC.code=cap /* " " " code to the capitol*/
|
||||
stateL= stateL code /*keep a list of all the US state codes*/
|
||||
stateN.code= name; w= max(w,length(name)) /*define the state's name; max width. */
|
||||
stateC.code= cap /* " " " code to the capital*/
|
||||
return /*return to invoker, SETSC is finished.*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue