Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -1,69 +0,0 @@
with Ada.Text_Io;
with Ada.Containers.Indefinite_Ordered_Maps;
procedure Merge_Maps is
use Ada.Text_Io;
type Key_Type is new String;
type Value_Type is new String;
package Maps is
new Ada.Containers.Indefinite_Ordered_Maps (Key_Type => Key_Type,
Element_Type => Value_Type);
use Maps;
function Merge (Original : Map; Update : Map) return Map is
Result : Map := Original;
Cur : Cursor := Update.First;
begin
while Has_Element (Cur) loop
if Original.Contains (Key (Cur)) then
Result.Replace_Element (Result.Find (Key (Cur)),
Element (Cur));
else
Result.Insert (Key (Cur), Element (Cur));
end if;
Next (Cur);
end loop;
return Result;
end Merge;
procedure Put_Map (M : Map) is
Cur : Cursor := M.First;
begin
while Has_Element (Cur) loop
Put (String (Key (Cur)));
Set_Col (12);
Put (String (Element (Cur)));
New_Line;
Next (Cur);
end loop;
end Put_Map;
Original : Map;
Update : Map;
Result : Map;
begin
Original.Insert ("name", "Rocket Skates");
Original.Insert ("price", "12.75");
Original.Insert ("color", "yellow");
Update.Insert ("price", "15.25");
Update.Insert ("color", "red");
Update.Insert ("year", "1974");
Result := Merge (Original, Update);
Put_Line ("Original:");
Put_Map (Original);
New_Line;
Put_Line ("Update:");
Put_Map (Update);
New_Line;
Put_Line ("Result of merge:");
Put_Map (Result);
New_Line;
end Merge_Maps;

View file

@ -1,5 +1,5 @@
-- 8 Aug 2025
include Settings
-- 23 Aug 2025
include Setting
say 'ASSOCIATIVE ARRAY: MERGE'
say version
@ -10,6 +10,7 @@ call CreateUpdate
call ShowUpdate
call MergeBaseUpdate
call ShowBase 'Merged'
call DumpVariables
exit
CreateBase:
@ -75,4 +76,4 @@ if WordPos(k,upda) = 0 then
upda.k=v
return
include Abend
include Math

View file

@ -1,5 +0,0 @@
set dict1 [dict create name "Rocket Skates" price 12.75 color yellow]
set dict2 [dict create price 15.25 color red year 1974]
dict for {key val} [dict merge $dict1 $dict2] {
puts "$key: $val"
}

View file

@ -1,29 +0,0 @@
set d1=createobject("Scripting.Dictionary")
d1.add "name", "Rocket Skates"
d1.add "price", 12.75
d1.add "color", "yellow"
set d2=createobject("Scripting.Dictionary")
d2.add "price", 15.25
d2.add "color", "red"
d2.add "year", 1974
set d3=createobject("Scripting.Dictionary")
for each k1 in d1.keys
if not d3.exists(k1) then
d3.add k1, d1(k1)
else
d3(k1)=d1(k1)
end if
next
for each k2 in d2.keys
if not d3.exists(k2) then
d3.add k2, d2(k2)
else
d3(k2)=d2(k2)
end if
next
for each k3 in d3.keys
wscript.echo k3 & vbtab & d3(k3)
next