Idea: swap with multiple arguments
Wyatt via Digitalmars-d
digitalmars-d at puremagic.com
Tue May 24 07:49:20 PDT 2016
On Tuesday, 24 May 2016 at 12:22:01 UTC, H. S. Teoh wrote:
>
> And why would you assume that it would rotate right? The
> default assumption, unless stated clearly and widely followed
> everywhere, is unclear and leads to misunderstandings. I'd
> rather unambiguously name them rotateRight and rotateLeft than
> the asymmetric rotate / rotateLeft.
>
In the APL family, we have dyadic ⌽ and ⊖:
3⌽⍳9 ⍝ left
4 5 6 7 8 9 1 2 3
¯3⌽⍳9 ⍝ right
7 8 9 1 2 3 4 5 6
3 3⍴⍳9
1 2 3
4 5 6
7 8 9
1⊖3 3⍴⍳9 ⍝ up
4 5 6
7 8 9
1 2 3
¯1⊖3 3⍴⍳9 ⍝ down
7 8 9
1 2 3
4 5 6
They rotate left and up in the positive case because that yields
the natural indexing order. Right rotation gives you a reverse
ordering.
-Wyatt
More information about the Digitalmars-d
mailing list