Created
June 1, 2011 01:23
-
-
Save yoppi/1001608 to your computer and use it in GitHub Desktop.
Recursive Function with Vim Script
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! Tree(lst, ret) | |
if empty(a:lst) | |
return a:ret | |
endif | |
let _ = a:ret + get(a:lst, 0) | |
return Tree(a:lst[1:-1], _) | |
endfunction | |
echo Tree(range(11), 0) | |
"=> 55 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
echo Score('abc') "=> 7
Solution: https://exercism.io/tracks/vimscript/exercises/scrabble-score/solutions/b3b78881542c467896ffc4b73e029542