Timeline for What is the way to get updated position in a list after dropping elements?
Current License: CC BY-SA 4.0
10 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Feb 29, 2020 at 20:23 | answer | added | kglr | timeline score: 2 | |
Feb 29, 2020 at 19:54 | history | edited | user13892 | CC BY-SA 4.0 |
added 327 characters in body
|
Feb 29, 2020 at 14:38 | answer | added | Edmund | timeline score: 2 | |
Feb 28, 2020 at 19:15 | comment | added | user13892 |
One dirty trick might be to do a ReplacePart on the original list to differentiate the element first then use this trick but that doesn't seem like a professional way of doing it. Is there a function that can target positions directly?
|
|
Feb 28, 2020 at 19:04 | comment | added | user13892 | Is there a way to look at the positions directly rather than looking at positions through the values of elements. Which is causing extra matching to occur. | |
Feb 28, 2020 at 18:59 | comment | added | user13892 |
@kglr incorrect behaviour for cyclePart[{e,b,c,d,e,f,g,h,i,e}->{b,d,i,j},5,2,True]
|
|
Feb 28, 2020 at 18:49 | comment | added | kglr |
...or cyclePart[list_ -> drop_, n_, \[CapitalDelta]n_, cycle_: True] := Module[{newlist = DeleteCases[list, Alternatives @@ drop]}, cyclePart[newlist -> {}, PositionIndex[newlist][list[[n]]], \[CapitalDelta]n, cycle]] ?
|
|
Feb 28, 2020 at 18:47 | comment | added | kglr |
cyclePart[list_ -> drop_, n_, \[CapitalDelta]n_, cycle_: True] := Module[{newlist = DeleteCases[list, Alternatives @@ drop]}, cyclePart[newlist -> {}, Position[newlist, list[[n]]], \[CapitalDelta]n, cycle]] ?
|
|
Feb 28, 2020 at 18:41 | history | edited | user13892 | CC BY-SA 4.0 |
added 35 characters in body; edited title
|
Feb 28, 2020 at 18:27 | history | asked | user13892 | CC BY-SA 4.0 |