Re: brain gymnastics (SPOILER!)

new topic     » topic index » view thread      » older message » newer message

On Thu, 1 Jun 2000 08:38:31 +0000, Tor Gausen <tor.gausen at C2I.NET> wrote:

> Check out this perfectly legal (promise!) Euphoria
> program, what value do you suppose will be printed?
>
>    integer i
>
>    i = 1
>
>    i = -i
>
>    i /= i+1
>
>    +i = +i
>
>    i *= i-1
>
>    -i = -i
>
>    ? i

ROFL! I like it! Deliberate bad formatting => confusing code.

With sensible formatting the code becomes:

integer i

i = 1
--> i = 1

i = -i
--> i = -1

i /=  ((i + 1 + i) = +i)
--> i /= (((-1) + 1 + (-1)) = +(-1))
--> i /= ((0 - 1) = -1)
--> i /= (-1 = -1)
--> i /= 1
--> i = -1 / 1
--> i = -1

i *= ((i - 1 - i) = -i)
--> i *= (((-1) - 1 - (-1)) = -(-1))
--> i *= ((-2 + 1) = 1)
--> i *= ( -1 = 1)
--> i *= 0
--> i = 0

? i -- prints '0'

Where the heck did you find this nightmare?! smile It's worse than the
sequence mungers I come up with!

Carl -- Cheered up for the day. smile

--
No carrier. Use paper bag instead (Y/n)?

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu