Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function! HasKey(dict, key)
- return has_key(a:dict, a:key)
- endfunction
- function! s:has_key(dict, key)
- return has_key(a:dict, a:key)
- endfunction
- function! Fold(list, init, f)
- let l:V = a:init
- for l:Elem in a:list
- let l:V = a:f(l:V, l:Elem)
- endfor
- return l:V
- endfunction
- function! s:fold(list, init, f)
- return Fold(a:list, a:init, a:f)
- endfunction
- function! s:main()
- echo {'foo': 42}->HasKey('foo')
- echo range(1,10)->Fold(0, {acc,n -> acc + n})
- echo {'foo': 42}->s:has_key('foo')
- echo range(1,10)->s:fold(0, {acc,n -> acc + n})
- let l:Percent = {x -> x * 100}
- echo (10.0 / 100.0)->l:Percent()
- echo 2->{n -> n * 2}
- echo 'hello'->{s -> execute('echon s')}
- echo HasKey({'foo': 42}, 'foo')
- echo Fold(range(1,10), 0, {acc,n -> acc + n})
- endfunction
- call s:main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement