Skip to content

Instantly share code, notes, and snippets.

@jkeesh
Created January 4, 2014 08:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jkeesh/8252967 to your computer and use it in GitHub Desktop.
Save jkeesh/8252967 to your computer and use it in GitHub Desktop.
proof of concept lexicon
function Lexicon(file){
this.data = {
'a': {
'b': {
's': {}
}
}
};
}
Lexicon.prototype.contains = function(word){
console.log("Contains: " + word + "?");
var curDict = this.data;
for(var i = 0; i < word.length; i++){
var curLetter = word.charAt(i);
if(curLetter in curDict){
curDict = curDict[curLetter]
}else{
return false;
}
}
return true;
}
var a = new Lexicon();
console.log(a.contains("abs"));
console.log(a.contains("abx"));
console.log(a);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment