Created
January 29, 2010 09:21
-
-
Save shenie/289582 to your computer and use it in GitHub Desktop.
dhanji's http://pastie.org/796264
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
public List<String> glom(String...a) { | |
Stack<String> stack = new Stack<String>(); | |
stack.push(""); | |
for (String s : a) { | |
if (s != "") { | |
stack.push(stack.pop() + s); | |
} else { | |
if (stack.peek() != "") { | |
stack.push(""); | |
} | |
} | |
} | |
if (stack.peek() == "") { | |
stack.pop(); | |
} | |
return Arrays.asList(stack.toArray(new String[stack.size()])); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment