Hi Everyone
Lets say I have a list
a = {15, 5, 14, 1, 6, 10, 9, 2, 13, 7, 16, 17, 11, 20, 8, 19, 18, 12,
3, 4}
and I wish to swap the numbers {1, 2, 3, 4} or more specifically rotate that sub list left or right within the larger list, of course the sub list could be any 4 numbers or more than 4.
My method has been to find the position of the 4 numbers in the main list and then working with a temporary variable for the first value, do a replace procedure and then the last number takes the value of the temp variable. It works ok but seems clumsy and not very expandable in that it needs a rewrite if I alter the number of items to swap. can any one see a more efficient method?
Thanking everyone in advance
P.