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 sympa.inria.fr (Postfix) with ESMTPS id B5AE17EE0C for ; Thu, 29 Nov 2012 02:06:39 +0100 (CET) Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of berenger@riken.jp) identity=pra; client-ip=134.160.33.161; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="berenger@riken.jp"; x-sender="berenger@riken.jp"; x-conformance=sidf_compatible Received-SPF: Pass (mail4-smtp-sop.national.inria.fr: domain of berenger@riken.jp designates 134.160.33.161 as permitted sender) identity=mailfrom; client-ip=134.160.33.161; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="berenger@riken.jp"; x-sender="berenger@riken.jp"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: Pass (mail4-smtp-sop.national.inria.fr: domain of postmaster@postman.riken.jp designates 134.160.33.161 as permitted sender) identity=helo; client-ip=134.160.33.161; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="berenger@riken.jp"; x-sender="postmaster@postman.riken.jp"; x-conformance=sidf_compatible; x-record-type="v=spf1" X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuIAALG0tlCGoCGhmWdsb2JhbABFrVySXg4BAQEBAQgLCwcUJ4IeAQEEATg2CgYLCxgJBBIPCQMCAQIBMxITBgIBAQ6HbAMJBgy1JQOJXow/gRqDJwOIXI0lgRyET4NfiXs X-IronPort-AV: E=Sophos;i="4.84,180,1355094000"; d="scan'208";a="164137560" Received: from postman1.riken.jp (HELO postman.riken.jp) ([134.160.33.161]) by mail4-smtp-sop.national.inria.fr with ESMTP; 29 Nov 2012 02:06:37 +0100 Received: from postman.riken.jp (postman1.riken.jp [127.0.0.1]) by postman.riken.jp (Postfix) with SMTP id AA44E2588002 for ; Thu, 29 Nov 2012 10:06:33 +0900 (JST) Received: from [172.27.98.103] (rikad98.riken.jp [134.160.214.98]) by postman.riken.jp (Postfix) with ESMTPA id 2F92D32A0047 for ; Thu, 29 Nov 2012 10:06:33 +0900 (JST) Message-ID: <50B6B519.6060305@riken.jp> Date: Thu, 29 Nov 2012 10:06:33 +0900 From: Francois Berenger User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: caml-list@inria.fr References: <50B595A4.50402@wwayneb.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-PMX-Version: 5.6.0.2009776, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2012.11.29.5415 Subject: Re: [Caml-list] List.fold_left vs. Hashtbl.fold 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 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 >