Try
let list=['02', '03', '03', '16', '17', '17', '28', '29', '29'] let unduplist=filter(copy(list), 'index(list, v:val, v:key+1)==-1')
. For the second question, see :h index() .
By the way, if
- all list items are strings;
- no empty lines;
- You do not need the order of the list items.
then you should probably use a dictionary instead: for a large number of lines, duplicate searches are faster (and really not required).
source share