Skip to content

Instantly share code, notes, and snippets.

@shenie
Created January 29, 2010 09:21
Show Gist options
  • Save shenie/289582 to your computer and use it in GitHub Desktop.
Save shenie/289582 to your computer and use it in GitHub Desktop.
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