Associative array/Merging: Difference between revisions

Realize in F#
(Realize in F#)
Line 218:
</lang>
 
=={{header|F_Sharp|F#}}==
<lang fsharp>
type N = |Price of float|Name of string|Year of int|Colour of string
let n=Map<string,N>[("name",Name("Rocket Skates"));("price",Price(12.75));("colour",Colour("yellow"))]
let g=Map<string,N>[("price",Price(15.25));("colour",Colour("red"));("year",Year(1974))]
let ng=(Map.toList n)@(Map.toList g)|>Map.ofList
printfn "%A" ng
</lang>
{{out}}
<pre>
map
[("colour", Colour "red"); ("name", Name "Rocket Skates");
("price", Price 15.25); ("year", Year 1974)]
</pre>
// Minimum positive multiple in base 10 using only 0 and 1. Nigel Galloway: March 9th., 2020
=={{header|Factor}}==
The <code>assoc-union</code> word does this. <code>assoc-union!</code> is a variant that mutates the first associative array.
2,172

edits