VimScript で、bind とか

部分適用的な処理とか。
すごく… C++ ライクです……。

[ソース]

function! s:placeholders(args_no)
    let func = {"args_no" : a:args_no}
    function! func.apply(...) dict
        return a:000[self.args_no]
    endfunction
    return func
endfunction
let _1 = s:placeholders(0)
let _2 = s:placeholders(1)
let _3 = s:placeholders(2)

function! s:bind(func, ...)
    let func = {"func" : a:func, "args" : a:000}
    function! func.apply(...) dict
        let args=[]
        for var in self.args
            if type(var) == type({}) && has_key(var, "apply")
                call add(args, call(var.apply, a:000, var))
            else
                call add(args, var)
            endif
            unlet var
        endfor
        return call(self.func, args)
    endfunction
    return func
endfunction


function! s:plus(a, b)
    return a:a + a:b
endfunction

function! s:minus(a, b)
    return a:a - a:b
endfunction

" 3 + 6
echo s:bind("s:plus", 3, _1).apply(6)
" 3 + 3
echo s:bind("s:plus", _1, _1).apply(3)
" 4 - 2
echo s:bind("s:minus", _1, _2).apply(4, 2) 
" 2 - 4
echo s:bind("s:minus", _2, _1).apply(4, 2) 
" ネストして評価したり
" (3 + 1) + (3 - 1)
echo s:bind("s:plus",
    \ s:bind("s:plus", _1, _2),
    \ s:bind("s:minus", _1, _2)).apply(3, 1)

[出力]

9
6
2
-2
6

こんな感じ。
まー書き方は Boost.Bind そのままですね。
placeholders を使用すれば、引数の順番も変えることが出来ます。
ひと通りやりたいことが出来たかな。