27 Nov 09:52
Re: beginner question about typing
From: pisethkem <pisethkem <at> yahoo.com>
Subject: Re: beginner question about typing
Newsgroups: gmane.comp.lang.ocaml.beginners
Date: 2008-11-27 08:52:18 GMT
Subject: Re: beginner question about typing
Newsgroups: gmane.comp.lang.ocaml.beginners
Date: 2008-11-27 08:52:18 GMT
--- In ocaml_beginners <at> yahoogroups.com, "ben.aurel" <ben.aurel <at> ...> wrote:
>
> hi
> I make another attempt with ocaml and it seems like it doesn't fit my
> brain yet.
>
> ---
> let max a b =
> if a > b then a else b
> ;;
>
> print_newline (max 3 5) ;;
>
> ---
>
> The error message is the following:
> This expression has type int but is here used with type unit
>
>
> If tried several things like 'int max' or casting like 'then int a',
> but it doesn't work.
>
> What am I doing wrong here?
> thanks
> ben
>
you miss the case when a = b
let max a b =
if a <= b then b else a;;
print_int (max 3 5);;
piseth kem
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch format to Traditional
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe
.
__,_._,___
RSS Feed