Are there any direct function to switch elements i,j in any list? or is necessary to create one with Do / If ? (I don´t ask for making me this function if it doesn´t exists)
My target is can switching positions i,j in {1,4,3,2,5} for example I tell switch(2,5) an obtain {1,5,3,2,4}
mylist[[{i,j}]]=mylist[[{j,i}]]– ciao Apr 19 '14 at 06:18Thank you
– Mika Ike Apr 19 '14 at 06:49m = {1, 4, 3, 2, 5}; idx = {1, 2, 4}; m[[idx]] = m[[Reverse[idx]]];I also do not know why you need to save the actual data in the position affected. You have the index of the positions switched there. So you can always obtain the data that was switched anytime. Save memory ! Just dooldData = m[[Reverse[idx]]]to read the old data – Nasser Apr 19 '14 at 06:52