Re: [Wrapl-discussion] K(expr1, ..., exprN)
Brought to you by:
rajamukherji
|
From: Raja M. <raj...@gm...> - 2010-05-24 10:30:45
|
Hi,
The problem is that, like all function calls, calling K(expr1, ..., exprN)
evaluates expr1, .., exprN first and then returns exprK. So both s <- "s"
and s <- "" are evaluated, in that order, but only if (2 > i) succeeds. So
for i = 9,8,..,2, neither s <- "s" or s <- "" are evaluated and s is "s"
from its initial value. Then when i = 1 or 0, both s <- "s" and s <- "" are
evaluated and s is "" afterwards.
Hope this clears things up,
Raja
On 24 May 2010 09:44, Roman Mishin <rom...@gm...> wrote:
> Hello.
>
> I am going through the Wrapl's tutorial and am trying to employ this
> function call: K(expr1, ..., exprN).
> I understand how it is intended to work and if K is an explicit integer, it
> works as expected, but if K is calculated, only expr1 is selected, no more.
>
> For example:
>
> MOD bottles;
>
> IMP IO.Terminal USE Out;
>
> VAR s <- "s"; DEF ob <- "of beer"; DEF otw <- "on the wall"; VAR i;
> EVERY i <- 9:to(0,-1) DO (
> ((2 > i) + 1)(s <- "s", s <- "");
> Out:write('{i} bottle{s} {ob} {otw}.\n');
> );
>
> END bottles.
>
> outputs:
> ...
> 2 bottles of beer on the wall.
> 1 bottle of beer on the wall.
> 0 bottle of beer on the wall.
>
> I want it to be:
> ...
> 2 bottles of beer on the wall.
> 1 bottle of beer on the wall.
> 0 bottles of beer on the wall.
>
> I am on Windows XP, Wrapl [1.1.5:864].
>
>
> ------------------------------------------------------------------------------
>
>
> _______________________________________________
> Wrapl-discussion mailing list
> Wra...@li...
> https://lists.sourceforge.net/lists/listinfo/wrapl-discussion
>
>
|