| Newsgroups |
gmane.comp.lang.ocaml.beginners |
| Message-ID |
<[email protected]> |
Thanks .
Now I understand where I did go wrong.
Roelof
John Whitington [email protected] [ocaml_beginners] schreef op
15-10-2014 14:32:
> Hi,
>
> You're using this syntax twice, nested:
>
> let <name> = <expression> in <another expression>
>
> which binds the <name> (e.g x, to the value of the <expression> e.g 1)
> in <another expression>.
>
> In your example, we can insert some parentheses, without changing the
> meaning of the expression. Can you see what's happening now?
>
> let x = 1 in (let x = 2 in x + x)
> --> let x = 1 in 4
> --> 4
>
> Thanks,
>
> John
>
> Roelof Wobben [email protected] [ocaml_beginners] wrote:
>> oke,
>>
>> I thought I had to read it as follows
>>
>> let x = 1 the first x in x + x is a 1
>> let x = 2 so the second x in x + x is a 2 so it will be 1 + 2 = 3
>>
>> Roelof
>>
>>
>>
>> Lukasz Stafiniak [email protected] [ocaml_beginners] schreef op
>> 15-10-2014 14:21:
>>> On Wed, Oct 15, 2014 at 2:17 PM, Roelof Wobben [email protected]
>>> <mailto:[email protected]> [ocaml_beginners]
>>> <[email protected]
>>> <mailto:[email protected]>> wrote:
>>>
>>> Hello,
>>>
>>> I have this programm :
>>>
>>> let x = 1 in let x = 2 in x + x
>>>
>>> I was expected to see a outcome of 3 but when I run it I see a
>>> outcome
>>> of 4 ,
>>>
>>> Can someone explain to me why ??
>>>
>>> If x is an integer, then x + x = 2 * x is an even number. 3 is not an
>>> even number so it cannot be equal to x + x for any x. Since x = 2,
>>> therefore x + x = 2 + 2 = 4.
>>>
>>> Regards.
>>
------------------------------------
------------------------------------
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/