File tree 2 files changed +30
-0
lines changed
2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change 5
5
Items toList:Items
6
6
Keys arity:Keys
7
7
Entries toListInd:Entries
8
+ Clone Exchange ToRecord
8
9
prepare
9
10
fun {Get M Key} M.Key end
10
11
proc {Put M Key Value} M.Key := Value end
@@ -68,4 +69,25 @@ prepare
68
69
(Lo#A.Lo)|{ArrayToListX A Lo+ 1 Hi}
69
70
end
70
71
end
72
+ DictClone = Dictionary.clone
73
+ ArrayClone = Array.clone
74
+ fun {Clone M}
75
+ if {IsDictionary M} then {DictClone M}
76
+ elseif {IsRecord M} then M
77
+ else {ArrayClone M} end
78
+ end
79
+ DictExchange = Dictionary.exchange
80
+ ArrayExchange = Array.exchange
81
+ proc {Exchange M Key Old New}
82
+ if {IsDictionary M} then {DictExchange M Key Old New}
83
+ elseif {IsRecord M} then M.Key= Old= New
84
+ else {ArrayExchange M Key Old New} end
85
+ end
86
+ DictToRecord = Dictionary.toRecord
87
+ ArrayToRecord = Array.toRecord
88
+ fun {ToRecord Label M}
89
+ if {IsDictionary M} then {DictToRecord Label M}
90
+ elseif {IsRecord M} then {Adjoin M Label}
91
+ else {ArrayToRecord Label M} end
92
+ end
71
93
end
Original file line number Diff line number Diff line change @@ -85,6 +85,14 @@ <H2>Exports</H2>
85
85
< DT > < CODE > {Mapping.entries +M ?L}</ CODE >
86
86
< DT > < CODE > {Mapping.toListInd +M ?L}</ CODE >
87
87
< DD > returns a list of the entries < CODE > Key#Value</ CODE > in the mapping
88
+ < DT > < CODE > {Mapping.clone +M1 ?M2}</ CODE >
89
+ < DD > returns a clone < CODE > M2</ CODE > of the mapping < CODE > M1</ CODE >
90
+ < DT > < CODE > {Mapping.exchange +M +Key ?Old +New}</ CODE >
91
+ < DD > atomically exchanges the value for < CODE > Key</ CODE > in mapping < CODE > M</ CODE > :
92
+ sets it to < CODE > New</ CODE > while returning < CODE > Old</ CODE >
93
+ < DT > < CODE > {Mapping.toRecord +Label +M ?R}</ CODE >
94
+ < DD > returns a record < CODE > R</ CODE > with label < CODE > Label</ CODE > representing
95
+ the entries in mapping < CODE > M</ CODE >
88
96
</ DL >
89
97
90
98
< HR >
You can’t perform that action at this time.
0 commit comments