It doesn't behave like that in my 1.9.6.16, in VS 2008 or 2010-beta.

It behaves just as expected. The type is ('State -> 'Key -> 'T -> 'State) -> 'State -> Map<'Key,'T> -> 'State, and it does a fold left.

eg.

1
2
3
4
5
6

let map = Map.of_list [ "amy",210; "fred",100; "jenny",200]

let fold = Map.fold (fun acc (k : string) v  -> if k.EndsWith("y") then acc @ [v] else acc) [] map

> fold;;
val it : int list = [210; 200]
By on 6/4/2009 4:45 AM ()

mine misbehaves, same as the op's... took me a while to realize what was going on when it refused to correctly infer my data types, then i realized that the sig wasn't the same as the fold_left it replaced...

By on 6/4/2009 6:07 AM ()