From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 98B737EE6B for ; Mon, 25 Nov 2013 02:36:16 +0100 (CET) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of berenger@riken.jp) identity=pra; client-ip=134.160.33.176; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="berenger@riken.jp"; x-sender="berenger@riken.jp"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of berenger@riken.jp designates 134.160.33.176 as permitted sender) identity=mailfrom; client-ip=134.160.33.176; receiver=mail2-smtp-roc.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 (mail2-smtp-roc.national.inria.fr: domain of postmaster@postman.riken.jp designates 134.160.33.176 as permitted sender) identity=helo; client-ip=134.160.33.176; receiver=mail2-smtp-roc.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: AnsCAFSoklKGoCGwhWdsb2JhbABZvSyDA4EzDgEBAQoLCxsogiUBAQUnEUARCxgJFg8JAwIBAgFFEwgBAYd9vCkXjw4WhB0DiUCKcYNjhkSPBQ X-IPAS-Result: AnsCAFSoklKGoCGwhWdsb2JhbABZvSyDA4EzDgEBAQoLCxsogiUBAQUnEUARCxgJFg8JAwIBAgFFEwgBAYd9vCkXjw4WhB0DiUCKcYNjhkSPBQ X-IronPort-AV: E=Sophos;i="4.93,764,1378850400"; d="scan'208";a="45096155" Received: from postman4.riken.jp (HELO postman.riken.jp) ([134.160.33.176]) by mail2-smtp-roc.national.inria.fr with ESMTP; 25 Nov 2013 02:36:14 +0100 Received: from postman.riken.jp (postman4.riken.jp [127.0.0.1]) by postman.riken.jp (Postfix) with SMTP id BBE298280F1 for ; Mon, 25 Nov 2013 10:36:11 +0900 (JST) Received: from [172.27.98.103] (rikad98.riken.jp [134.160.214.98]) by postman.riken.jp (Postfix) with ESMTPA id A253F7F803F for ; Mon, 25 Nov 2013 10:36:11 +0900 (JST) Message-ID: <5292A98B.9010202@riken.jp> Date: Mon, 25 Nov 2013 10:36:11 +0900 From: Francois Berenger User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: caml-list@inria.fr References: <1384873538.80445.YahooMailNeo@web160506.mail.bf1.yahoo.com> In-Reply-To: <1384873538.80445.YahooMailNeo@web160506.mail.bf1.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2013.11.25.12715 Subject: Re: [Caml-list] short-circuit in Real World Ocaml ch 3 deserves a comment On 11/20/2013 12:05 AM, Jean Saint-Remy wrote: > [...] > The example code using pattern matching appears to be a "let rec" > short-circuit which I believe deserves a comment in the book. It appears > to be puzzling, we are binding a "zero" to the head of the list in order > to drop it? I think it is a fine example of OCaml that should be > encouraged, not just an isolated case. > > let rec drop_zero ls = match ls with > | [] -> [] > | 0 :: tl -> drop_zero tl > | hd :: tl -> hd :: drop_zero tl > ;; Are we really speaking of some "real world" OCaml? This code is not tail recursive and can be replaced by a one liner using List.filter from the standard library.