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: 5170 Reporter: bluestorm Status: resolved (set by @alainfrisch on 2016-12-07T16:01:17Z) Resolution: suspended Priority: normal Severity: feature Version: 3.12.0 Category: standard library Tags: patch Monitored by:@gasche mehdi @ygrek@hcarty
Bug description
The nice new Map.merge function iterates on two streams simultaneously.
While fold, iter and map's implementation enforce a left-to-right (or "increasing key") evaluation order, merge is unspecified :
let rec merge f s1 s2 =
match (s1, s2) with ...
| (Node (l1, v1, d1, r1, h1), _) when h1 >= height s2 ->
let (l2, d2, r2) = split v1 s2 in
concat_or_join (merge f l1 l2) v1 (f v1 (Some d1) d2) (merge f r1 r2)
| ...
It may be nice to enforce its evaluation order so that the function [f] is applied in increasing key order :
let rec merge f s1 s2 =
match (s1, s2) with
(Empty, Empty) -> Empty
| (Node (l1, v1, d1, r1, h1), _) when h1 >= height s2 ->
let (l2, d2, r2) = split v1 s2 in
let l' = merge f l1 l2 in
let d' = f v1 (Some d1) d2 in
let r' = merge f r1 r2 in
concat_or_join l' v1 d' r'
| (_, Node (l2, v2, d2, r2, h2)) ->
let (l1, d1, r1) = split v2 s1 in
let l' = merge f l1 l2 in
let d' = f v2 d1 (Some d2) in
let r' = merge f r1 r2 in
concat_or_join l' v2 d' r'
| _ ->
assert false
Note : the predicate-handling functions for_all, exists, filter and partition apply their predicates node first, then left branch, then right branch. Should they also be considered for left-right-ification ?
The text was updated successfully, but these errors were encountered:
Hmm; am I the only who thinks that this is distinctly not a bug?
I don't really like overspecifying the behaviour of some function; this really locks in the current implementation and potentially makes upgrading/fixing bugs harder.
Original bug ID: 5170
Reporter: bluestorm
Status: resolved (set by @alainfrisch on 2016-12-07T16:01:17Z)
Resolution: suspended
Priority: normal
Severity: feature
Version: 3.12.0
Category: standard library
Tags: patch
Monitored by: @gasche mehdi @ygrek @hcarty
Bug description
The nice new Map.merge function iterates on two streams simultaneously.
While fold, iter and map's implementation enforce a left-to-right (or "increasing key") evaluation order, merge is unspecified :
It may be nice to enforce its evaluation order so that the function [f] is applied in increasing key order :
Note : the predicate-handling functions
for_all
,exists
,filter
andpartition
apply their predicates node first, then left branch, then right branch. Should they also be considered for left-right-ification ?The text was updated successfully, but these errors were encountered: