Last active
November 19, 2016 17:02
-
-
Save rhysd/4f32dc8706448a9ec54842968ac70a7f to your computer and use it in GitHub Desktop.
This file contains 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:fold(list, init, pred) abort | |
let acc = a:init | |
for item in a:list | |
let acc = a:pred(acc, item) | |
endfor | |
return acc | |
endfunction | |
echo s:fold([1, 2, 3, 4, 5], 0, {acc, i -> acc + i}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment