From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 3CDA57FADB for ; Wed, 5 Nov 2014 20:14:50 +0100 (CET) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of r.wobben@home.nl) identity=pra; client-ip=212.54.34.164; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="r.wobben@home.nl"; x-sender="r.wobben@home.nl"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of r.wobben@home.nl) identity=mailfrom; client-ip=212.54.34.164; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="r.wobben@home.nl"; x-sender="r.wobben@home.nl"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@smtpq1.gn.mail.iss.as9143.net) identity=helo; client-ip=212.54.34.164; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="r.wobben@home.nl"; x-sender="postmaster@smtpq1.gn.mail.iss.as9143.net"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsYBANh1WlTUNiKknGdsb2JhbABcg2JZAYMFuT6QWodNAiN6FgEBAQEBEQEBAQEBBg0JCRQuhAMBAQQjBAsBOwoRCQIaAgUEEgsCAgkDAgECATMSEwYCAQEOiBoDFgmaHJxfjlwDhksLAQEBAR2BLY9rFoJhgVQFhR0FjgyDRIcegTE9hgaKWIgCa4JLAQEB X-IPAS-Result: AsYBANh1WlTUNiKknGdsb2JhbABcg2JZAYMFuT6QWodNAiN6FgEBAQEBEQEBAQEBBg0JCRQuhAMBAQQjBAsBOwoRCQIaAgUEEgsCAgkDAgECATMSEwYCAQEOiBoDFgmaHJxfjlwDhksLAQEBAR2BLY9rFoJhgVQFhR0FjgyDRIcegTE9hgaKWIgCa4JLAQEB X-IronPort-AV: E=Sophos;i="5.07,321,1413237600"; d="scan'208,217";a="105023562" Received: from smtpq1.gn.mail.iss.as9143.net ([212.54.34.164]) by mail2-smtp-roc.national.inria.fr with ESMTP; 05 Nov 2014 20:14:46 +0100 Received: from [212.54.34.135] (helo=smtp4.gn.mail.iss.as9143.net) by smtpq1.gn.mail.iss.as9143.net with esmtp (Exim 4.71) (envelope-from ) id 1Xm62X-0007Az-Ls for caml-list@inria.fr; Wed, 05 Nov 2014 20:14:45 +0100 Received: from 524acd6d.cm-4-3d.dynamic.ziggo.nl ([82.74.205.109] helo=[192.168.0.100]) by smtp4.gn.mail.iss.as9143.net with esmtp (Exim 4.71) (envelope-from ) id 1Xm62X-0007J3-9l for caml-list@inria.fr; Wed, 05 Nov 2014 20:14:45 +0100 Message-ID: <545A7729.8030404@home.nl> Date: Wed, 05 Nov 2014 20:14:49 +0100 From: Roelof Wobben User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: caml-list@inria.fr References: <545A708C.6060900@home.nl> <545A72F7.8020109@home.nl> In-Reply-To: Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Ziggo-spambar: --- X-Ziggo-spamscore: -3.9 X-Ziggo-spamreport: ALL_TRUSTED=-1,BAYES_00=-1.9,CM_CTENC_8BIT=0.1,CM_META_TB_NOARR=0.5,HTML_MESSAGE=0.001,MIME_HTML_ONLY=0.001,PROLO_STOCK_G2=0.3,PROLO_TRUST_RDNS=-3,PROLO_YSPAM=0.1,RDNS_DYNAMIC=0.982 X-Ziggo-Spam-Status: No X-Spam-Flag: No Subject: Re: [Caml-list] why is the variable here unbound.
Thanks,

Roelof


Amirhossein Vakili schreef op 5-11-2014 19:57:
Yes. That is correct.

Amir

On Wed, Nov 5, 2014 at 1:56 PM, Roelof Wobben <r.wobben@home.nl> wrote:
Oke,

Now the line means that that I call the function length2 with the list and acc as 0 the first time.

Roelof

Amirhossein Vakili schreef op 5-11-2014 19:53:
Hi Roelof,

Your last line is not a correct term. "acc 0 list2 list" means that "acc" is a function, which has not been defined anywhere, and as a result, it is unbounded. The correct form is the following:

let length list =
           let rec length2 list2 acc =
           match list2 with
           | [] -> acc
           | x::xs -> length2 xs (acc + 1)
       in length2 list 0;;

Hope this helps,
Amir


On Wed, Nov 5, 2014 at 1:46 PM, Roelof Wobben <r.wobben@home.nl> wrote:
Hello,

I asked this question also on the beginners list but till now no respons.

I have this :

let length list =
    let rec length2 list2 acc =
        match list2 with
           | [] -> acc
           | x::xs -> length2 xs (acc + 1)
    in acc 0 list2 list ;;

But as soon as I copie it into the ocaml prompt I see a message that the acc in the part in acc 0 list2 list is unbound.

Roelof



--
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