Last active
January 2, 2016 02:39
-
-
Save todashuta/8238878 to your computer and use it in GitHub Desktop.
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
" Vim script でアッカーマン関数 | |
function! s:ack(m, n) | |
if a:m == 0 | |
return a:n + 1 | |
elseif a:n == 0 | |
return s:ack(a:m - 1, 1) | |
else | |
return s:ack(a:m - 1, s:ack(a:m, a:n - 1)) | |
endif | |
endfunction | |
" s:ack(3, 4) を実行するのに必要な maxfuncdepth を求めてみる | |
for s:i in reverse(range(100, 150)) | |
let &maxfuncdepth = s:i | |
try | |
call s:ack(3, 4) " => 125 | |
echo printf('maxfuncdepth=%d OK.', s:i) | |
catch | |
echo printf('maxfuncdepth=%d Failed.', s:i) | |
break | |
endtry | |
endfor |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment