Hi Gabriele

> How do you write A * B - C * D in REBOL without using parens? You
> need to use parens or use the notation:

You can do it without parens by mixing infix and prefix forms:

>> - 4 * 5 3 * 4
== 12

I looked for a more complex example and noted that even with parens, the
result from REBOL may be surprising, because of the way the interpreter
evaluates parens.

>> - (4 * 5) ((3 * 4) + (2 * 3))
== 18                                    ; not the naive expected result
>> (4 * 5) - ((3 * 4) + (2 * 3))
== 2                                      ; the expected result

But I found a way to do this without parens (readability becoming an issue)

>> + - + 3 * 4 2 * 3 4 * 5
== 2

This is kind of fun, eh?

Regards
-Larry

PS I suspect it can be shown that with suitable rearrangement of terms and
with both infix and prefix forms available, that parens are not needed.

Counter example?

----- Original Message -----
From: Gabriele Santilli <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, October 21, 2000 4:46 AM
Subject: [REBOL] Re: Expression evaluator (an example of parsing blocks)
-------snip--------------------

-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to