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

Bug#327211: Wrong order in Map.fold



Sven Luther <sven.luther@wanadoo.fr> writes:

> 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 ?

Yes.

falk@juist:~% ocaml
        Objective Caml version 3.08.3

# module IntMap = Map.Make(struct type t = int let compare = compare end);;
module IntMap :
  sig
    type key = int
    type +'a t
    val empty : 'a t
    val is_empty : 'a t -> bool
    val add : key -> 'a -> 'a t -> 'a t
    val find : key -> 'a t -> 'a
    val remove : key -> 'a t -> 'a t
    val mem : key -> 'a t -> bool
    val iter : (key -> 'a -> unit) -> 'a t -> unit
    val map : ('a -> 'b) -> 'a t -> 'b t
    val mapi : (key -> 'a -> 'b) -> 'a t -> 'b t
    val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
    val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int
    val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool
  end
# let make_set = List.fold_left (fun s x -> IntMap.add x 0 s) IntMap.empty;;
val make_set : IntMap.key list -> int IntMap.t = <fun>
# let s = make_set [23; 17; 616];;
val s : int IntMap.t = <abstr>
# IntMap.fold (fun x _ l -> l @ [x]) s [];;
- : IntMap.key list = [616; 23; 17]
#

-- 
	Falk



Reply to: