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