Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: David Allsopp <dra-news@metastack.com>
To: "'Tie Cheng'" <chengtie@gmail.com>,
	"'caml-list@yquem.inria.fr'" <caml-list@yquem.inria.fr>
Subject: RE: [Caml-list] AtomMap: build a list of all the elements in a map
Date: Mon, 21 Feb 2011 12:44:31 +0000	[thread overview]
Message-ID: <E51C5B015DBD1348A1D85763337FB6D9490F09C9@Remus.metastack.local> (raw)
In-Reply-To: <AANLkTingFB4Jfem__Zjoq6DS-WYiYdzHUz6sYgGcb8r5@mail.gmail.com>

Tie Cheng wrote:
> I have posted a question on Caml-beginners, but have not got 
> response so far... guess maybe you could here... I have defined 
> "type AT = A AtomMap.t". Do you know how to build a function 
> "f: AT -> (atom * A) list" which returns a list of all the 
> elements in a map?
> I am trying to combine AtomMap.fold, AtomMap.Iter 
> (in this manual http://cristal.inria.fr/~fpottier/alphaCaml/alphaCaml.pdf)
> to do so... But it seems that unlike List.folder_left, AtomMap.fold
> does not accept list as argument: val fold : (key -> 'a -> 'b -> 'b)
> -> 'a t -> 'b -> 'b, there it is not convenient to build a list 
> progressively here...

I don't see how that function signature differs from what you expect so sorry if that's because I don't know anything about alphaCaml!

What's wrong with:

fold (fun key value acc -> (key, value)::acc)) atomMap []

The signature for [fold] is simply like the signature for List.fold_right rather than List.fold_left.


David


  reply	other threads:[~2011-02-21 12:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-21 12:40 Tie Cheng
2011-02-21 12:44 ` David Allsopp [this message]
2011-02-21 13:05 ` Raphael Proust

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=E51C5B015DBD1348A1D85763337FB6D9490F09C9@Remus.metastack.local \
    --to=dra-news@metastack.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=chengtie@gmail.com \
    /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