[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#327211: Wrong order in Map.fold



On Thu, Sep 08, 2005 at 02:08:31PM +0200, Falk Hueffner wrote:
> Package: ocaml-nox
> Version: 3.08.3-7
> Severity: normal
> File: /usr/bin/ocamlc
> 
> falk@juist:/tmp% cat test.ml
> module IntMap = Map.Make(struct type t = int let compare = compare end);;
> let make_set = List.fold_left (fun s x -> IntMap.add x 0 s) IntMap.empty;;
> let () =
>   let s = make_set [23; 17; 616]
>   in
>     IntMap.fold (fun x _ () -> Printf.printf "%d\n" x) s ()
> ;;
> falk@juist:/tmp% ocamlc test.ml && ./a.out
> 616
> 23
> 17
> 
> However, the manual says (and I would expect) that keys are enumerated
> in *increasing* order. Map.iter is correct in this regard.

I am not entirely sure how this works, but are you sure the fold is not doing
this right, but the printf being done in reversed order ?

In any case, this is an upstream issue.

Friendly,

Sven Luther




Reply to: