Thread overview
Swap operator ?
Oct 10, 2007
BLS
Oct 10, 2007
Jascha Wetzel
Oct 10, 2007
Matti Niemenmaa
Oct 11, 2007
Michael Gnail
Oct 11, 2007
Bill Baxter
Oct 12, 2007
David Brown
Oct 11, 2007
BLS
October 10, 2007
Not really nessesary, but nice to have...
int a = 1;
int b = 2;
a <=> b // a == 2, b == 1
October 10, 2007
BLS wrote:
> Not really nessesary, but nice to have...
> int a = 1;
> int b = 2;
> a <=> b // a == 2, b == 1

i use:

void swap(T)(ref T a, ref T b) {
  T t = a;
  a = b;
  b = t;
}

int a = 1;
int b = 2;
swap(a,b);
October 10, 2007
BLS wrote:
> Not really nessesary, but nice to have...
> int a = 1;
> int b = 2;
> a <=> b // a == 2, b == 1

Or multiple return values, and then:

a, b = b, a;

-- 
E-mail address: matti.niemenmaa+news, domain is iki (DOT) fi
October 11, 2007
Matti Niemenmaa wrote:
> BLS wrote:
>> Not really nessesary, but nice to have...
>> int a = 1;
>> int b = 2;
>> a <=> b // a == 2, b == 1
> 
> Or multiple return values, and then:
> 
> a, b = b, a;
> 
This is the *python* way, and I love that too.
October 11, 2007
BLS schrieb:
> Not really nessesary, but nice to have...
> int a = 1;
> int b = 2;
> a <=> b // a == 2, b == 1

Sorry folks, just have recognized that this stuff is allready part of the chapel thread; B
		
October 11, 2007
Michael Gnail wrote:
> Matti Niemenmaa wrote:
>> BLS wrote:
>>> Not really nessesary, but nice to have...
>>> int a = 1;
>>> int b = 2;
>>> a <=> b // a == 2, b == 1
>>
>> Or multiple return values, and then:
>>
>> a, b = b, a;
>>
> This is the *python* way, and I love that too.

I don't know where that syntax came from, but but I'm pretty sure it predates python by a good bit.  Probably Ada or something.

--bb
October 12, 2007
On Fri, Oct 12, 2007 at 08:15:30AM +0900, Bill Baxter wrote:

>>> a, b = b, a;
>>>
>> This is the *python* way, and I love that too.
>
> I don't know where that syntax came from, but but I'm pretty sure it predates python by a good bit.  Probably Ada or something.

Ada doesn't have multiple assignment.  CLU had it in 1974, though.

David