Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: [Caml-list] Queue.fold give wrong order?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From:
Subject: Re: [Caml-list] Queue.fold give wrong order?
Hi,

From: Tom Wilkie <tom@acunu.com>
Date: Tue, 19 Jan 2010 15:10:43 +0000
> Is Queue.fold going over items in the wrong order?  It says "equivalent to
> List.fold_left" but I would expect the behaviour to be, when inserting items 1,
> then 2, then 3 a fold would be given items in that order?
It's already the case.

> # Queue.fold (fun acc a -> a::acc) [] q;;
> - : int list = [3; 2; 1]
Your (fun acc a -> a::acc) is first called with args [] and 1, and
yields a next value for accu of [1]; and so on.

HTH,
Bruno.