Created
August 11, 2012 08:19
-
-
Save dahu/3322468 to your computer and use it in GitHub Desktop.
Simple Flatten() for lists in VimL
This file contains hidden or 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! Flatten(list) | |
| let val = [] | |
| for elem in a:list | |
| if type(elem) == type([]) | |
| call extend(val, Flatten(elem)) | |
| else | |
| call extend(val, [elem]) | |
| endif | |
| unlet elem | |
| endfor | |
| return val | |
| endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment