Mercurial > vim
comparison src/testdir/test55.in @ 5747:ddc3f32a4b21 v7.4.218
updated for version 7.4.218
Problem: It's not easy to remove duplicates from a list.
Solution: Add the uniq() function. (LCD)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Tue, 25 Mar 2014 18:24:23 +0100 |
parents | b43363a7b4c7 |
children | adc4a84f72eb |
comparison
equal
deleted
inserted
replaced
5746:798d83d15327 | 5747:ddc3f32a4b21 |
---|---|
321 : $put =string(a:000) | 321 : $put =string(a:000) |
322 :catch | 322 :catch |
323 : $put ='caught ' . v:exception | 323 : $put ='caught ' . v:exception |
324 :endtry | 324 :endtry |
325 :" | 325 :" |
326 :" reverse() and sort() | 326 :" reverse(), sort(), uniq() |
327 :let l = ['-0', 'A11', 2, 'xaaa', 4, 'foo', 'foo6', [0, 1, 2], 'x8'] | 327 :let l = ['-0', 'A11', 2, 2, 'xaaa', 4, 'foo', 'foo6', 'foo', [0, 1, 2], 'x8', [0, 1, 2], 1.5] |
328 :$put =string(uniq(copy(l))) | |
328 :$put =string(reverse(l)) | 329 :$put =string(reverse(l)) |
329 :$put =string(reverse(reverse(l))) | 330 :$put =string(reverse(reverse(l))) |
330 :$put =string(sort(l)) | 331 :$put =string(sort(l)) |
331 :$put =string(reverse(sort(l))) | 332 :$put =string(reverse(sort(l))) |
332 :$put =string(sort(reverse(sort(l)))) | 333 :$put =string(sort(reverse(sort(l)))) |
334 :$put =string(uniq(sort(l))) | |
333 :" | 335 :" |
334 :" splitting a string to a List | 336 :" splitting a string to a List |
335 :$put =string(split(' aa bb ')) | 337 :$put =string(split(' aa bb ')) |
336 :$put =string(split(' aa bb ', '\W\+', 0)) | 338 :$put =string(split(' aa bb ', '\W\+', 0)) |
337 :$put =string(split(' aa bb ', '\W\+', 1)) | 339 :$put =string(split(' aa bb ', '\W\+', 1)) |