Created
October 27, 2013 18:25
-
-
Save davidchambers/7186099 to your computer and use it in GitHub Desktop.
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
concat = (lists...) -> | |
[].concat(lists...) | |
_traverse = (list, path, f) -> | |
if list.length is 0 | |
f(path) | |
else | |
for item, idx in list | |
_traverse(concat(list.slice(0, idx), list.slice(idx + 1)), | |
concat(path, [item]), f) | |
traverse = (list, f) -> | |
_traverse(list, [], f) | |
traverse(['foo', 'bar', 'baz', 'quux'], (path) -> console.log(path.join(' > '))) |
Author
davidchambers
commented
Oct 27, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment