Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -0,0 +1,4 @@
[map
("foo" 13)
("bar" 42)
("baz" 77)]

View file

@ -1,5 +1,5 @@
m = { => } # empty, future inserted keys will be ordered
h = { : } # empty, future inserted keys will not be ordered
m = { => } # empty ordered map, future inserted keys will be ordered
h = { -> } # empty hash map, future inserted keys will not be ordered
m = { 'foo' => 42, 'bar' => 100 } # with ordered keys
h = { 'foo' : 42, 'bar' : 100 } # with unordered keys
h = { 'foo' -> 42, 'bar' -> 100 } # with unordered keys

View file

@ -0,0 +1,2 @@
(setq my-table (make-hash-table))
(puthash 'key 'value my-table)

View file

@ -0,0 +1,2 @@
(setq my-table (make-hash-table :test 'equal))
(puthash "key" 123 my-table)

View file

@ -1,16 +1,23 @@
// declare a nil map variable, for maps from string to int
var x map[string] int
var x map[string]int
// make an empty map
x = make(map[string] int)
x = make(map[string]int)
// make an empty map with an initial capacity
x = make(map[string] int, 42)
x = make(map[string]int, 42)
// set a value
x["foo"] = 3
// getting values
y1 := x["bar"] // zero value returned if no map entry exists for the key
y2, ok := x["bar"] // ok is a boolean, true if key exists in the map
// removing keys
delete(x, "foo")
// make a map with a literal
x = map[string] int {
"foo": 2, "bar": 42, "baz": -1,
x = map[string]int{
"foo": 2, "bar": 42, "baz": -1,
}

View file

@ -0,0 +1,27 @@
julia> hash = {'a' => 97, 'b' => 98} # list keys/values
{'a'=>97,'b'=>98}
julia> hash = {c => int(c) for c = 'a':'d'} # dict comprehension
{'a'=>97,'c'=>99,'b'=>98,'d'=>100}
julia> hash['é'] = 233 ; hash # add an element
{'a'=>97,'c'=>99,'b'=>98,'é'=>233,'d'=>100}
julia> hash = Dict() # create an empty dict
Dict{Any,Any}()
julia> for c = 'a':'d' hash[c] = int(c) end ; hash # fill it
{'a'=>97,'c'=>99,'b'=>98,'d'=>100}
julia> hash = (Char=>Int64)['a' => 97, 'b' => 98] # create a typed dict
['a'=>97,'b'=>98]
julia> hash["a"] = 1 # type mismatch
ERROR: no method convert(Type{Char}, ASCIIString)
in setindex! at dict.jl:533
julia> hash = Dict(['a','b','c'], [97,98,99]) # constructor
['a'=>97,'c'=>99,'b'=>98]
julia> typeof(hash) # type is infered correctly
Dict{Char,Int64} (constructor with 3 methods

View file

@ -0,0 +1 @@
m = containers.Map({'a' 'b' 'C'}, [1 2 3]);

View file

@ -0,0 +1,4 @@
m = containers.Map;
m('a') = 1;
m('b') = 2;
m('C') = 3;

View file

@ -0,0 +1 @@
m = containers.Map([51 72 37], {'fiftyone' 'seventytwo' 'thirtyseven'});

View file

@ -0,0 +1,4 @@
m = containers.Map('KeyType', 'double', 'ValueType', 'any');
m(51) = 'fiftyone';
m(72) = 'seventytwo';
m(37) = 'thirtyseven';

View file

@ -0,0 +1,41 @@
MODULE AssociativeArray;
IMPORT
ADT:Dictionary,
Object:Boxed,
Out;
TYPE
Key = STRING;
Value = Boxed.LongInt;
VAR
assocArray: Dictionary.Dictionary(Key,Value);
iterK: Dictionary.IterKeys(Key,Value);
iterV: Dictionary.IterValues(Key,Value);
aux: Value;
k: Key;
BEGIN
assocArray := NEW(Dictionary.Dictionary(Key,Value));
assocArray.Set("ten",NEW(Value,10));
assocArray.Set("eleven",NEW(Value,11));
aux := assocArray.Get("ten");
Out.LongInt(aux.value,0);Out.Ln;
aux := assocArray.Get("eleven");
Out.LongInt(aux.value,0);Out.Ln;Out.Ln;
(* Iterate keys *)
iterK := assocArray.IterKeys();
WHILE (iterK.Next(k)) DO
Out.Object(k);Out.Ln
END;
Out.Ln;
(* Iterate values *)
iterV := assocArray.IterValues();
WHILE (iterV.Next(aux)) DO
Out.LongInt(aux.value,0);Out.Ln
END
END AssociativeArray.

View file

@ -1,10 +1,10 @@
DECLARE
type assocArrayType is record (
type ThisIsNotAnAssocArrayType is record (
myShape VARCHAR2(20),
mySize number,
isActive BOOLEAN
);
assocArray assocArrayType;
assocArray ThisIsNotAnAssocArrayType ;
BEGIN
assocArray.myShape := 'circle';

View file

@ -3,8 +3,8 @@
key0 = '0'
key1 = 'key0'
stem. = '.' /* Initialize the associative array 'stem' to '.' */
stem.key1 = 'value0' /* Set a specific key/value pair */
stem. = '.' /* Initialize the associative array 'stem' to '.' */
stem.key1 = 'value0' /* Set a specific key/value pair */
Say '<stem key="'key0'" value="'stem.key0'" />' /* Display a value for a key that wasn't set */
Say '<stem key="'key1'" value="'stem.key1'" />' /* Display a value for a key that was set */
Say 'stem.key0= 'stem.key /* Display a value for a key that wasn't set */
Say 'stem.key1= 'stem.key1 /* Display a value for a key that was set */

View file

@ -0,0 +1,6 @@
REM Create a table to associate keys with values
CREATE TABLE associative_array ( KEY_COLUMN VARCHAR2(10), VALUE_COLUMN VARCHAR2(100)); .
REM Insert a Key Value Pair
INSERT (KEY_COLUMN, VALUE_COLUMN) VALUES ( 'VALUE','KEY');.
REM Retrieve a key value pair
SELECT aa.value_column FROM associative_array aa where aa.key_column = 'KEY';

View file

@ -0,0 +1,4 @@
typeset -A hash
hash=( [key1]=val1 [key2]=val2 )
hash[key3]=val3
echo "${hash[key3]}"

View file

@ -0,0 +1 @@
declare -A hash

View file

@ -0,0 +1,20 @@
" Creating a dictionary with some initial values
let dict = {"one": 1, "two": 2}
" Retrieving a value
let two_a = dict["two"]
let two_b = dict.two
let two_c = get(dict, "two", "default value for missing key")
" Modifying a value
let dict["one"] = 1.0
let dict.two = 2.0
" Adding a new value
let dict["three"] = 3
let dict.four = 4
" Removing a value
let one = remove(dict, "one")
unlet dict["two"]
unlet dict.three