Created
March 20, 2010 17:05
-
-
Save tyru/338769 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! s:uniq(list) "{{{ | |
let dict = {} | |
let counter = 1 | |
for i in a:list | |
let dict[i] = counter | |
let counter += 1 | |
endfor | |
function! s:cmp(a, b) | |
return a:a == a:b ? 0 : a:a > a:b ? 1 : -1 | |
endfunction | |
function! s:_(a, b) | |
let [a, b] = [a:a, a:b] | |
return eval(s:expr) | |
endfunction | |
try | |
let s:expr = 's:cmp(dict[a], dict[b])' | |
return sort(keys(dict), 's:_') | |
finally | |
" コメントアウト有りだとE133: return not inside function | |
" コメントアウト無しだとE130: Unknown function s:cmp | |
" | |
" なんだかちゃんとfunctionとendfunctionの対応が理解できてないような... | |
" | |
delfunc s:cmp | |
delfunc s:_ | |
unlet s:expr | |
endtry | |
endfunction "}}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment