September Morn Update
This commit is contained in:
parent
4e2d22a71d
commit
aac6731f2c
6856 changed files with 141342 additions and 21127 deletions
|
|
@ -1,12 +1,12 @@
|
|||
import system'collections.
|
||||
import system'collections;
|
||||
|
||||
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";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
import system'collections.
|
||||
import system'collections;
|
||||
|
||||
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";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
program AssociativeArrayCreation;
|
||||
{$IFDEF FPC}{$MODE DELPHI}{$ENDIF}
|
||||
{$IFDEF WINDOWS}{$APPTYPE CONSOLE}{$ENDIF}
|
||||
uses Generics.Collections;
|
||||
var
|
||||
lDictionary: TDictionary<string, Integer>;
|
||||
begin
|
||||
lDictionary := TDictionary<string, Integer>.Create;
|
||||
try
|
||||
lDictionary.Add('foo', 5);
|
||||
lDictionary.Add('bar', 10);
|
||||
lDictionary.Add('baz', 15);
|
||||
lDictionary.AddOrSetValue('foo', 6); // replaces value if it exists
|
||||
finally
|
||||
lDictionary.Free;
|
||||
end;
|
||||
end.
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
program AssociativeArrayCreation;
|
||||
{$IFDEF WINDOWS}{$APPTYPE CONSOLE}{$ENDIF}
|
||||
{$MODE DELPHI}
|
||||
uses fgl;
|
||||
|
||||
var
|
||||
lDictionary: TFPGMap<string, Integer>;
|
||||
begin
|
||||
lDictionary := TFPGMap<string, Integer>.Create;
|
||||
try
|
||||
lDictionary.Add('foo', 5);
|
||||
lDictionary.Add('bar', 10);
|
||||
lDictionary.Add('baz', 15);
|
||||
finally
|
||||
lDictionary.Free;
|
||||
end;
|
||||
end.
|
||||
|
|
@ -0,0 +1 @@
|
|||
let associative_array = {key1=1,key2=2}
|
||||
|
|
@ -1,23 +1,31 @@
|
|||
; empty associative array has two names
|
||||
;;; empty associative array
|
||||
#empty
|
||||
#()
|
||||
; or short form
|
||||
#e
|
||||
|
||||
; creating the new empty associative array
|
||||
;;; creating the new empty associative array
|
||||
(define empty-map #empty)
|
||||
|
||||
; creating associative array with values
|
||||
;;; creating associative array with values
|
||||
(define my-map (list->ff '(
|
||||
(1 . 100)
|
||||
(2 . 200)
|
||||
(7 . 777))))
|
||||
;;; or in short form (available from Ol version 2.1)
|
||||
(define my-map '{
|
||||
(1 . 100)
|
||||
(2 . 200)
|
||||
(7 . 777)})
|
||||
|
||||
; add new key-value pair to the existing associative array
|
||||
;;; add new key-value pair to the existing associative array
|
||||
(define my-new-map (put my-map 'the-key 'the-value))
|
||||
|
||||
; print our arrays
|
||||
;;; print our arrays
|
||||
(print empty-map)
|
||||
; ==> #()
|
||||
|
||||
(print my-map)
|
||||
; ==> #((1 . 100) (2 . 200) (7 . 777))
|
||||
|
||||
(print my-new-map)
|
||||
; ==> #((1 . 100) (2 . 200) (7 . 777) (the-key . the-value))
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
$hashtable = @{
|
||||
"key1" = "value 1"
|
||||
"key2" = 5
|
||||
key2 = 5 # if the key name has no spaces, no quotes are needed.
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,2 +1,20 @@
|
|||
$hashtable.key1 # value 1
|
||||
$hashtable['key2'] # 5
|
||||
# Case insensitive keys, both end up as the same key:
|
||||
$h=@{}
|
||||
$h['a'] = 1
|
||||
$h['A'] = 2
|
||||
$h
|
||||
|
||||
Name Value
|
||||
---- -----
|
||||
a 2
|
||||
|
||||
# Case sensitive keys:
|
||||
$h = New-Object -TypeName System.Collections.Hashtable
|
||||
$h['a'] = 1
|
||||
$h['A'] = 2
|
||||
$h
|
||||
|
||||
Name Value
|
||||
---- -----
|
||||
A 2
|
||||
a 1
|
||||
|
|
|
|||
|
|
@ -1,6 +1,2 @@
|
|||
$addressObj= "" | Select-Object nameStr,street1Str,street2Str,cityStr,stateStr,zipStr
|
||||
$addressObj.nameStr = [string]"FirstName LastName"
|
||||
$addressObj.street1Str= [string]"1 Main Street"
|
||||
$addressObj.cityStr= [string]"Washington DC"
|
||||
$addressObj.stateStr= [string]"DC"
|
||||
$addressObj.zipStr= [string]"20009"
|
||||
$hashtable.key1 # value 1
|
||||
$hashtable['key2'] # 5
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
$obj = [PSCustomObject]@{
|
||||
"key1" = "value 1"
|
||||
key2 = 5
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue