From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 60EA4BBAF for ; Tue, 19 Jan 2010 16:53:55 +0100 (CET) X-IronPort-AV: E=Sophos;i="4.49,303,1262559600"; d="scan'208";a="41761768" Received: from waco.inria.fr ([128.93.25.2]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 19 Jan 2010 16:53:55 +0100 Received: from waco.inria.fr (localhost [127.0.0.1]) by waco.inria.fr (8.13.6/8.13.6) with ESMTP id o0JFrt4c025900; Tue, 19 Jan 2010 16:53:55 +0100 Received: (from verlyck@localhost) by waco.inria.fr (8.13.6/8.12.10/Submit) id o0JFrtqh025899; Tue, 19 Jan 2010 16:53:55 +0100 Date: Tue, 19 Jan 2010 16:53:55 +0100 Message-Id: <201001191553.o0JFrtqh025899@waco.inria.fr> From: Bruno Verlyck To: Tom Wilkie Cc: caml-list@yquem.inria.fr In-reply-to: "tom@acunu.com"'s message of Tue, 19 Jan 2010 15:10:43 +0000 Subject: Re: [Caml-list] Queue.fold give wrong order? From: Bruno.Verlyck@inria.fr References: Mime-Version: 1.0 (generated by tm-edit 7.106) Content-Type: text/plain; charset=US-ASCII X-Spam: no; 0.00; inserting:01 caml-list:01 int:01 behaviour:01 accu:02 bruno:03 bruno:03 args:05 tue:06 fold:06 fold:06 inria:06 inria:06 queue:07 queue:07 Hi, From: Tom Wilkie 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.