Re: last item. no output
| Newsgroups | gmane.comp.lang.ocaml.beginners |
|---|---|
| Message-ID | <[email protected]> |
Le 18/10/2014 13:30, Roelof Wobben [email protected] [ocaml_beginners] a écrit : > I think your remark has to do with this problem : > > last [1] ;; > Error: This expression has type int but an expression was expected of type > > 'a list And? Sébastian is explaining you that you compiled a program test.native that do nothing. When you call it, you are passing either "[]" or "[1]" to this program. Yes: those are strings. But, since your program does nothing, nothing is done. Next steps are : - understand how to make a program do something - understand how to pass parameters to your program Let us consider the first problem. When an ocaml module is loaded, everything is evaluated, from the first line to the last line. Create a program with `let doit () = print_endline "Bye!"`. The only thing it does is defining doit. This function types as: unit -> unit If you add 'let () = doit ()', you would now have doit function be called. Let's keep the "how to pass and use an parameter" for a next time… Salutations -- Matthieu Dubuget Guide d’autodéfense numérique : http://guide.boum.org