Idea: swap with multiple arguments

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Mon May 23 17:16:16 PDT 2016


On Mon, May 23, 2016 at 04:01:08PM -0400, Andrei Alexandrescu via Digitalmars-d wrote:
> So swap(a, b) swaps the contents of a and b. This could be easily
> generalized to multiple arguments such that swap(a1, a2, ..., an)
> arranges things such that a1 gets an, a2 gets a1, a3 gets a2, etc. I
> do know applications for three arguments. Thoughts? -- Andrei

As others have said, 'swap' is a horrible name for this. I'd go with
'rotate', but then there's the question of which direction it rotates.
Conceivably, it's equally valid for an to get a1, a1 to get a2, etc..
So 'rotateRight' would be most unambiguous, though a handful to type.


T

-- 
What's an anagram of "BANACH-TARSKI"?  BANACH-TARSKI BANACH-TARSKI.


More information about the Digitalmars-d mailing list