From: Francois Berenger <berenger@riken.jp>
To: caml-list@inria.fr
Subject: Re: [Caml-list] List.fold_left vs. Hashtbl.fold
Date: Thu, 29 Nov 2012 10:06:33 +0900 [thread overview]
Message-ID: <50B6B519.6060305@riken.jp> (raw)
In-Reply-To: <CAK=fH+ht_8VqYhrjSrSGCiRyBk6xAh1R0_JxBNXf8tHDsQ3PrA@mail.gmail.com>
On 11/29/2012 01:21 AM, David House wrote:
> This is a perfect example of why we wrote the core library:
>
> https://bitbucket.org/yminsky/ocaml-core/wiki/Home
>
> In core, most of the iteration functions take their closure argument
> as a labelled ~f. So you can say List.fold_left my_list ~f:my_func, or
> List.fold_left ~f:my_func my_list.
For those who only need labels, there are:
Module MoreLabels.Hashtbl
http://caml.inria.fr/pub/docs/manual-ocaml/libref/MoreLabels.Hashtbl.html
and
Module ListLabels
http://caml.inria.fr/pub/docs/manual-ocaml/libref/ListLabels.html
> This tiny syntactic cost allows you lay out code much more logically:
> sometime you have a big long list, so you don't want the name of the
> function lost somewhere, way down the page. Sometimes it's the other
> way round, and you have a bit lambda that you're folding with, but you
> don't want the name of the list to be some anonymous bit of text a
> very long way away from the word "fold".
>
> On Wed, Nov 28, 2012 at 4:40 AM, William Smith <bills@wwayneb.com> wrote:
>> List.fold_left expects the List as the 3rd parameter with the second
>> parameter being the initial value.
>>
>> Hashtbl.fold expects the Hasthbl as the second parameter with the 3rd
>> parameter being the initial value... just the opposite of List.fold_left.
>>
>> Is there a reason for this difference? I'm having trouble remembering
>> which goes which way. If it's not a historical accident, I'd like to have
>> a understanding of why they are different to help me know which is which.
>>
>> Thanks,
>>
>> Bill
>>
>> --
>> Caml-list mailing list. Subscription management and archives:
>> https://sympa.inria.fr/sympa/arc/caml-list
>> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
>> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
next prev parent reply other threads:[~2012-11-29 1:06 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-28 4:40 William Smith
2012-11-28 16:17 ` Lukasz Stafiniak
2012-11-28 16:25 ` Malcolm Matalka
2012-11-28 16:21 ` David House
2012-11-29 1:06 ` Francois Berenger [this message]
2012-11-28 16:42 ` Oliver Bandel
2012-11-28 17:11 ` Adrien
2012-11-28 17:41 ` Virgile Prevosto
2012-11-29 0:07 ` Jacques Garrigue
[not found] ` <CAPFanBG04BiwJuPkV80__Ondmg1N8OEg4DokiXqDReg3ycNBdA@mail.gmail.com>
2012-11-28 17:25 ` Gabriel Scherer
2012-11-28 17:37 ` Lukasz Stafiniak
2012-11-30 3:06 William Smith
2012-11-30 9:53 ` Gabriel Scherer
2012-11-30 10:06 ` Stefano Zacchiroli
2012-11-30 16:00 ` Gabriel Scherer
2012-11-30 16:48 ` Daniel Bünzli
2012-11-30 11:34 ` Daniel Bünzli
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=50B6B519.6060305@riken.jp \
--to=berenger@riken.jp \
--cc=caml-list@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