Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Tom Wilkie <tom@acunu.com>
To: caml-list@yquem.inria.fr
Cc: Tom Wilkie <tom@acunu.com>
Subject: Queue.fold give wrong order?
Date: Tue, 19 Jan 2010 15:10:43 +0000	[thread overview]
Message-ID: <F0AD2B48-279E-4121-8242-F56F2EE6642F@acunu.com> (raw)

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 = Queue.create ();;
val q : '_a Queue.t = <abstr>
# Queue.add 1 q;;
- : unit = ()
# Queue.add 2 q;;     
- : unit = ()
# Queue.add 3 q;;
- : unit = ()
# Queue.fold (fun acc a -> a::acc) [] q;;
- : int list = [3; 2; 1]
# Queue.iter (fun a -> print_endline (string_of_int a)) q;;
1
2
3
- : unit = ()


             reply	other threads:[~2010-01-19 15:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-19 15:10 Tom Wilkie [this message]
2010-01-19 15:22 ` [Caml-list] " David Allsopp

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=F0AD2B48-279E-4121-8242-F56F2EE6642F@acunu.com \
    --to=tom@acunu.com \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox