You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 576 Reporter: administrator Assigned to:@alainfrisch Status: resolved (set by @alainfrisch on 2016-12-08T10:57:53Z) Resolution: suspended Priority: normal Severity: feature Category: standard library Tags: patch, junior_job Related to:#2748 Monitored by:@thizanne@gasche
Bug description
same definition as Map.add, except that it will throw an exception if the
key already exists. (I think that this should have been the default
behaviour of add, and the current add should have been called replace)
let rec add x data = function
Empty ->
Node(Empty, x, data, Empty, 1)
| Node(l, v, d, r, h) as t ->
let c = Ord.compare x v in
if c = 0 then
raise XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
else if c < 0 then
bal (add x data l) v d r
else
bal l v d (add x data r)
I agree this would be a reasonable addition. Since we are moving away from using exception, the function should return an option (None if the map already contained the element). A similar function should also be added to Set (and to Labeled versions). Marking as suspended, but a PR is welcome.
Original bug ID: 576
Reporter: administrator
Assigned to: @alainfrisch
Status: resolved (set by @alainfrisch on 2016-12-08T10:57:53Z)
Resolution: suspended
Priority: normal
Severity: feature
Category: standard library
Tags: patch, junior_job
Related to: #2748
Monitored by: @thizanne @gasche
Bug description
same definition as Map.add, except that it will throw an exception if the
key already exists. (I think that this should have been the default
behaviour of add, and the current add should have been called replace)
/mattias
File attachments
The text was updated successfully, but these errors were encountered: