vim-slimeã§ãfor ... in ...ãæ§æã便å©ã«è»¢éãã
Vimã«ã¯vim-slimeã¨ãã便å©ãªãã©ã°ã¤ã³ããããVimä¸ã§æ¸ãã¦ããã³ã¼ãããtmuxãscreençµç±ã§å¥ãã¤ã³ã«è»¢éãããã¨ãã§ããã
ããã®ä½ãå¬ãããã¨ããã¨ããå·¦ã¯Pythonã½ã¼ã¹ã³ã¼ãããå³ã¯Pythonã®å®è¡çµæãã¿ãããªæãã§ãæ¸ããªããå®è¡ã§ãããâ
RStudioã¨ã使ã£ããã¨ããã人ã¯ã便å©ããã¤ã¡ã¼ã¸ãæãã¯ãã
Download and Install RStudio | RProgramming.net
foræã®ä¸ã ãå®è¡ãããã¨ããiterableãªãªãã¸ã§ã¯ãã®å
é ãä»®ã§å
¥ãããã±ã¼ã¹ããããã
ä¸è¨ã®ãããªã³ã¼ããã
array = [1, 2, 3] for i, x in enumerate(array): print(i, x)
ä¸è¨ã®ããã«å®è¡ãããã
i, x = enumerate(array).next() print(x)
Vimåã足ããªãã®ã§ãä¸è¨ã®ãããªæé ã§ã¨ãããã対å¿ããã
~/.vim/after/ftplugin/python.vim ãéãã¦ãä¸è¨ã®ãããªé¢æ°ã追å
function! _EscapeText_python(text) if exists('g:slime_python_ipython') && len(split(a:text,"\n")) > 1 return "%cpaste\n".a:text."--\n" else let no_empty_lines = substitute(a:text, '\n\s*\ze\n', "", "g") let stripped = substitute(substitute(a:text, '^\s*', '', ''), '\s*$', '', '') if stripped[:3] == 'for ' && stripped[-2:-2] == ':' return substitute(stripped[4:-3], ' in ', ' = iter(', '') . ').next() ' else return substitute(no_empty_lines, "\n", " ", "g") end end endfunction
ããã§ã
for i, x in enumerate(array):
ã
i, x = iter(enumerate(array)).next() # i = 0; x = 1
ã§è»¢éããããæé«