Re: Where did my thinking take the wrong turn
| Newsgroups | gmane.comp.lang.ocaml.beginners |
|---|---|
| Message-ID | <[email protected]> |
Christophe Troestler schreef op 5-11-2014 20:49: > Hi, > > On Wed, 5 Nov 2014 20:18:23 +0100, Roelof Wobben [email protected] > [ocaml_beginners] wrote: >> >> Sorry for asking so much but I still have problems with the easy task of >> the 99 Ocaml problems. >> >> I now have to revert a list. >> >> I have this : >> >> let reverse list = >> let rec reverse2 list2 acc = >> match list2 with >> | [] -> acc >> | x::xs -> reverse2 (x::acc) xs > > The order of arguments matters. Take a piece of paper and compute > manually (taking great care of the details) the recursive calls of > « reverse2 [1;2;3] [] ». Thanks, A good tip when Im stuck. And I made the thinking error that list must be changed but list2 is the same as list and acc holds the new list and not the old one. Roelof