# [Wellington-pm] SEND + MORE = MONEY

Malcolm Allison Malcolm.Allison at computerland.co.nz
Wed Mar 2 21:20:21 PST 2005

```of course you could always break out of integer math and then there is a
very simple value that means both
\$a + \$a == 1   and
\$a * 2 == 1

are resolvable.

Malcolm.

-----Original Message-----
From: wellington-pm-bounces at pm.org [mailto:wellington-pm-bounces at pm.org]
On Behalf Of Steve Wray
Sent: Thursday, 3 March 2005 6:15 p.m.
To: Wellington Perl Mongers (Perl user group)
Subject: Re: [Wellington-pm] SEND + MORE = MONEY

Malcolm Allison wrote:
> so \$a + \$a == 1 if \$a != \$a?
>
> this seems a little like cheating to me  ;)

Depends on how well-behaved the arithmetic operators are with respect to
side-effects: operators changing their operands 'behind your back' like
some sort functions that don't *return* a sorted list; they change the
list argument you give them into a sorted list.

Since side-effects are allowed in some languages, like perl, and since
it may be possible in a sufficiently ill-designed language, , to have an
arithmetic operator 'side-effect' in a really disastrous way, and indeed
\$a + \$a may come to == 1 when \$a starts as 1 and the + operator
decrements it by 1 part way through the operation.

\$a + \$a == 1 is only guaranteed in languages that don't allow
side-effects, eg prolog, haskell, caml, maybe even lisp.

It can really help when trying to figure out what a program does,
because you can always be sure that whatever happens, happens 'in front'

of you and that no operators or functions will make any state changes
which don't involve their return values. This gets just a little messy
when it comes to IO
:)

> In message <422694C1.7010600 at vilain.net>, Sam Vilain writes:
>
>>   use Quantum::Superpositions;
[snip]
>
> \$a + \$a == 1  is possible if the first \$a is taken as 1, and the
> second \$a is taken as 0 (or vice versa).  Where as there is no value
> in \$a which can be multiplied by 2 and yeild 1 (you get 2 or 0).

_______________________________________________
Wellington-pm mailing list
Wellington-pm at pm.org
http://mail.pm.org/mailman/listinfo/wellington-pm
```