Data update
This commit is contained in:
parent
4d5544505c
commit
4924dd0264
3073 changed files with 55820 additions and 4408 deletions
|
|
@ -0,0 +1,6 @@
|
|||
(import std.Dict)
|
||||
|
||||
(let d (dict "key" "value" 5 12))
|
||||
|
||||
(print (dict:get d 5))
|
||||
(print (dict:get d "key"))
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
# Create a table to associate a key with 0 or more values
|
||||
CREATE TABLE associative_array (KEY_COLUMN VARCHAR(10), VALUE_COLUMN VARCHAR(100));
|
||||
# Insert a Key Value pair
|
||||
INSERT INTO associative_array (KEY_COLUMN, VALUE_COLUMN) VALUES ('KEY', 'VALUE');
|
||||
# Retrieve a key value pair
|
||||
SELECT aa.value_column FROM associative_array aa where aa.key_column = 'KEY';
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
CREATE TABLE associative_array (KEY_COLUMN VARCHAR, VALUE_COLUMN VARCHAR);
|
||||
# Insert a Key Value pair
|
||||
INSERT INTO associative_array VALUES ('KEY', 'VALUE');
|
||||
# Retrieve a key value pair
|
||||
SELECT aa.value_column FROM associative_array aa where aa.key_column = 'KEY';
|
||||
|
|
@ -0,0 +1 @@
|
|||
CREATE TABLE aa (KEY_COLUMN VARCHAR UNIQUE NOT NULL, VALUE_COLUMN VARCHAR NOT NULL);
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
INSERT into aa VALUES ('k', 1), ('l', 2);
|
||||
from aa;
|
||||
INSERT into aa VALUES ('k', 3);
|
||||
|
|
@ -0,0 +1 @@
|
|||
SELECT aa FROM aa LIMIT 1;
|
||||
|
|
@ -0,0 +1 @@
|
|||
select unnest({'KEY_COLUMN': 'k', 'VALUE_COLUMN': 1});
|
||||
|
|
@ -0,0 +1 @@
|
|||
SELECT info.* FROM (SELECT {'a': 1, 'b': 2 } as info);
|
||||
|
|
@ -0,0 +1 @@
|
|||
SELECT '{"a": 1, "A": 2}'::JSON as j;
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
class Main {
|
||||
static public function main() {
|
||||
var map = [1 => "one", 2 => "two"];
|
||||
trace(map);
|
||||
$type(map);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
-- Create a map of key, value pairs.
|
||||
local planets = {
|
||||
Mercury = 1,
|
||||
Venus = 2,
|
||||
Earth = 3,
|
||||
Mars = 4,
|
||||
Jupiter = 5,
|
||||
Saturn = 6,
|
||||
Uranus = 7,
|
||||
Neptune = 8,
|
||||
Pluto = 9
|
||||
}
|
||||
|
||||
-- Print it
|
||||
-- Note that order is not guaranteed.
|
||||
for k, v in planets do print(k, v) end
|
||||
print()
|
||||
|
||||
-- Create a new one by inverting the key, value pairs.
|
||||
local planets2 = planets:invert()
|
||||
|
||||
-- Print it.
|
||||
-- Now treated as an array with indices 1 to 9
|
||||
-- which guarantees order.
|
||||
for k, v in planets2 do print($"{k} {v}") end
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
/* Rexx */
|
||||
|
||||
key0 = '0'
|
||||
key1 = 'key0'
|
||||
|
||||
stem. = '.' /* Initialize the associative array 'stem' to '.' */
|
||||
stem.key1 = 'value0' /* Set a specific key/value pair */
|
||||
|
||||
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 */
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
/*REXX program shows how to set/display values for an associative array.*/
|
||||
/*┌────────────────────────────────────────────────────────────────────┐
|
||||
│ The (below) two REXX statements aren't really necessary, but it │
|
||||
│ shows how to define any and all entries in a associative array so │
|
||||
│ that if a "key" is used that 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). │
|
||||
└────────────────────────────────────────────────────────────────────┘*/
|
||||
stateC.=' [not defined yet] ' /*sets any/all state capitols. */
|
||||
stateN.=' [not defined yet] ' /*sets any/all state names. */
|
||||
/*┌────────────────────────────────────────────────────────────────────┐
|
||||
│ In REXX, when a "key" is used, it's normally stored (internally) │
|
||||
│ 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, ...).│
|
||||
└────────────────────────────────────────────────────────────────────┘*/
|
||||
stateC.ca='Sacramento'; stateN.ca='California'
|
||||
stateC.nd='Bismarck' ; stateN.nd='North Dakota'
|
||||
stateC.mn='St. Paul' ; stateN.mn='Minnesota'
|
||||
stateC.dc='Washington'; stateN.dc='District of Columbia'
|
||||
stateC.ri='Providence'; stateN.ri='Rhode Island and Providence Plantations'
|
||||
|
||||
say 'capital of California is' stateC.ca
|
||||
say 'capital of Oklahoma is' stateC.ok
|
||||
yyy='RI'
|
||||
say 'capital of' stateN.yyy "is" stateC.yyy
|
||||
/*stick a fork in it, we're done.*/
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
-- 8 Aug 2025
|
||||
include Settings
|
||||
|
||||
say 'ASSOCIATIVE ARRAY: CREATION'
|
||||
say version
|
||||
say
|
||||
say 'Basic examples...'
|
||||
cap.='Unknown'
|
||||
cap.be='Brussels'
|
||||
cap.fr='Paris'
|
||||
cap.uk='London'
|
||||
call Capital 'BE'
|
||||
call Capital 'UK'
|
||||
call Capital 'NO'
|
||||
day.='Unknown'; week.=day.
|
||||
day.jan.2=2; week.jan.2=1
|
||||
day.mar.17=76; week.mar.17=12
|
||||
day.aug.7=219; week.aug.7=32
|
||||
call Calendar 'JAN',2
|
||||
call Calendar 'AUG',7
|
||||
call Calendar 'MAY',16
|
||||
say
|
||||
say 'Keys can have any value...'
|
||||
a.cat='civet'; say 'a.cat =' a.cat
|
||||
a1='dog'; a.a1='pitbull'
|
||||
a2=a1; say 'a.'a2 '=' a.a2
|
||||
a1='x.y.z'; a.a1='periods'
|
||||
a2=a1; say 'a.'a2 '=' a.a2
|
||||
a1='x y z'; a.a1='spaces'
|
||||
a2=a1; say 'a.'a2 '=' a.a2
|
||||
a1='ÀÁÂÃÄÅ'; a.a1='special characters'
|
||||
a2=a1; say 'a.'a2 '=' a.a2
|
||||
say
|
||||
if Pos('Regina',version) > 0 then
|
||||
call Library
|
||||
call SysDumpVariables
|
||||
exit
|
||||
|
||||
Capital:
|
||||
arg country
|
||||
say 'The capital of' country 'is' cap.country
|
||||
return
|
||||
|
||||
Calendar:
|
||||
arg mm,dd
|
||||
say mm dd 'is day no' day.mm.dd 'and week no' week.mm.dd
|
||||
return
|
||||
|
||||
Library:
|
||||
call RxFuncAdd 'SysLoadFuncs','RegUtil','SysLoadFuncs'
|
||||
call SysLoadFuncs
|
||||
return
|
||||
|
||||
include Abend
|
||||
|
|
@ -1 +0,0 @@
|
|||
declare -A hash
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
const std = @import("std");
|
||||
|
||||
pub fn main() !void {
|
||||
const stdout = std.io.getStdOut().writer();
|
||||
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
||||
const allocator = gpa.allocator();
|
||||
|
||||
var hash_map = std.StringHashMap(f64).init(allocator);
|
||||
defer hash_map.deinit();
|
||||
|
||||
try hash_map.put("pi", 3.14159265);
|
||||
try hash_map.put("e", 2.71828183);
|
||||
try hash_map.put("phi", 1.61803399);
|
||||
|
||||
try stdout.print("{d}\n", .{hash_map.get("pi").?});
|
||||
try stdout.print("{d}\n", .{hash_map.get("e").?});
|
||||
try stdout.print("{d}\n", .{hash_map.get("phi").?});
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
const std = @import("std");
|
||||
|
||||
const Entity = struct {
|
||||
name: []const u8,
|
||||
hp: i32,
|
||||
};
|
||||
|
||||
pub fn main() !void {
|
||||
const stdout = std.io.getStdOut().writer();
|
||||
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
||||
const allocator = gpa.allocator();
|
||||
|
||||
var hash_map = std.AutoHashMap(u32, Entity).init(allocator);
|
||||
defer hash_map.deinit();
|
||||
|
||||
try hash_map.put(123, .{ .name = "Zombie", .hp = 20 });
|
||||
try hash_map.put(456, .{ .name = "Bat", .hp = 6 });
|
||||
try hash_map.put(789, .{ .name = "Pig", .hp = 10 });
|
||||
|
||||
try stdout.print("{s:6}: HP = {d:3}\n", hash_map.get(123).?);
|
||||
try stdout.print("{s:6}: HP = {d:3}\n", hash_map.get(456).?);
|
||||
try stdout.print("{s:6}: HP = {d:3}\n", hash_map.get(789).?);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue