Re: last item. no output

"Sébastien Dailly [email protected] [ocaml_beginners]" <[email protected]>
Newsgroups gmane.comp.lang.ocaml.beginners
Message-ID <[email protected]>

Le 18/10/2014 11:21, Roelof Wobben [email protected] [ocaml_beginners] a 
écrit :
> Hello,
>
> I try to solve the first challenge from the 99 ocaml problems where I
> have to find the last item in a list.
>
> So I have this :
>
> let rec last list =
> match list with
> | [] -> []
> | [x] -> x
> | hd :: tl -> last tl
> ;;
>
> I saved it into a file called test.ml and build it with corebuild
> test,native.
> But when I do ,/test.native [] or ./test.native [1] I see total no output.
>

Hello,

I think your are confusing 2 things :

- arguments in a function
- arguments in a program

When you do ./test.native [] you give the string « [] » to the ocaml 
program. This is not automagicaly passed to the function  « last ».

Actualy, your program has a function which is never called…

Hope this help,

-- 
Sébastien Dailly


------------------------------------

------------------------------------

Archives up to December 31, 2011 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners
The archives of the very official ocaml list (the seniors' one) can be found at http://caml.inria.fr
Attachments are banned and you're asked to be polite, avoid flames etc.
------------------------------------

Yahoo Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/ocaml_beginners/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/ocaml_beginners/join
    (Yahoo! ID required)

<*> To change settings via email:
    [email protected] 
    [email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo Groups is subject to:
    https://info.yahoo.com/legal/us/yahoo/utos/terms/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.