Random Suggestion: Swap Operator <=>?
"Jérôme M. Berger"
jeberger at free.fr
Fri Jul 17 10:45:47 PDT 2009
Michiel Helvensteijn wrote:
> Leandro Lucarella wrote:
>
>> A more general solution is supporting tuples in the language, then you can
>> do something like:
>> a, b = b, a;
>
> That's a great feature. But even if it's available, I'd use swap, because:
>
> * I wouldn't have to mention each variable twice
> * It would use move-operations rather than copy operations
>
> Parallel assignment is still useful for other stuff, like traversing the
> fibonachi sequence with two variables :-)
>
> (a, b) <- (b, a + b);
>
Or when you need to reorder more than two variables:
a, b, c, d = b, d, a, c;
Jerome
--
mailto:jeberger at free.fr
http://jeberger.free.fr
Jabber: jeberger at jabber.fr
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: OpenPGP digital signature
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20090717/ffba0fe3/attachment.pgp>
More information about the Digitalmars-d
mailing list