From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 99126BBAF for ; Tue, 19 Jan 2010 16:10:47 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsBALxZVUvRVdvikGdsb2JhbACbQD8BAQEBCQkMBxMDu0KEMwQ X-IronPort-AV: E=Sophos;i="4.49,303,1262559600"; d="scan'208";a="54306212" Received: from mail-ew0-f226.google.com ([209.85.219.226]) by mail4-smtp-sop.national.inria.fr with ESMTP; 19 Jan 2010 16:10:47 +0100 Received: by ewy26 with SMTP id 26so1083713ewy.3 for ; Tue, 19 Jan 2010 07:10:45 -0800 (PST) Received: by 10.216.88.67 with SMTP id z45mr2492820wee.112.1263913845528; Tue, 19 Jan 2010 07:10:45 -0800 (PST) Received: from weems.theisland.acunu.com ([91.143.78.44]) by mx.google.com with ESMTPS id p37sm7957270gvf.8.2010.01.19.07.10.44 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 19 Jan 2010 07:10:44 -0800 (PST) From: Tom Wilkie Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Subject: Queue.fold give wrong order? Date: Tue, 19 Jan 2010 15:10:43 +0000 Message-Id: Cc: Tom Wilkie To: caml-list@yquem.inria.fr Mime-Version: 1.0 (Apple Message framework v1077) X-Mailer: Apple Mail (2.1077) X-Spam: no; 0.00; inserting:01 ocaml:01 val:01 abstr:01 iter:01 endline:01 int:01 int:01 behaviour:01 caml:02 objective:02 string:02 unit:03 unit:03 let:03 Dear all 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? Is there a good reason for this? Could be have a rev_fold for the = opposite order please? Thanks Tom # ocaml Objective Caml version 3.10.2 # open Queue;; # let q =3D Queue.create ();; val q : '_a Queue.t =3D # Queue.add 1 q;; - : unit =3D () # Queue.add 2 q;; =20 - : unit =3D () # Queue.add 3 q;; - : unit =3D () # Queue.fold (fun acc a -> a::acc) [] q;; - : int list =3D [3; 2; 1] # Queue.iter (fun a -> print_endline (string_of_int a)) q;; 1 2 3 - : unit =3D ()