Skip to content

Instantly share code, notes, and snippets.

@reverendpaco
Created July 26, 2010 22:41
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 reverendpaco/491373 to your computer and use it in GitHub Desktop.
Save reverendpaco/491373 to your computer and use it in GitHub Desktop.
-- this will be the complicated case
insertNode contextNode@TrieNode{children=childNodes,nodeType=oldNodeType}
SharedPrefixDatum { shared = sharedPrefix ,
suffixS = sourceSuffix@(s:ss),
suffixT = targetSuffix@(t:ts)}
= newForkNode {children = ourTwoNewNodes }
where newForkNode = nonWordNode sharedPrefix
ourTwoNewNodes = Map.fromList [(s,newSourceSuffixNode),(t,newTargetSuffixNode) ]
newSourceSuffixNode = wordNode sourceSuffix
newTargetSuffixNode = contextNode{ wordFragment = targetSuffix}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment