etymology-cli
Version:
To get the source of the words from http : //www.etymonline.com/
39 lines (32 loc) • 563 B
JavaScript
/**
*
* Stack implementation for manipulating string
*
*/
var stack = '';
isEmpty = function() {
return stack == '';
}
pop = function() {
var c = top();
stack = stack.slice(0, -1);
return c;
}
top = function() {
return stack.slice(-1);
}
push = function(c) {
stack += c;
}
getpair = function(c) {
if ((c == ')' && top() == '(') || (c == ']' && top() == '[') || (c == top() && c == '\"')) {
pop();
return c;
} else if (c == '[' || c == '(' || c == '\"') {
push(c);
}
if (!isEmpty()) {
return top();
}
return '';
}