Rotations are anagrams, and _1&A. is reverse. An equivalent rotation
algorithm is "reverse the first and last parts of the list, then reverse
the entire list".
NB. rotation using reversal
rotate =: [: |. |.@{. , |.@}.
3 (|. -: rotate) 'abcdefg'
1
3. Arithmetic of rotations (Dan Bron)
Date: Fri, 30 May 2014 18:42:06 -0400
From: Dan Bron <[email protected]>
To: [email protected]
Subject: [Jprogramming] Arithmetic of rotations
Message-ID: <PC1993201405301842060057c8ca11bf@thinkpad-2013>
Content-Type: text/plain; charset=iso-8859-1
While trying to implement the Nautical Bell task on RosettaCode [1], I
needed an arithmetic way to express a rotation. The short story is clocks
on ships are origin-1, whereas modern clocks are origin zero (midnight is
00:00:00.000).
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm