Created
May 22, 2017 01:20
-
-
Save kunigami/c9d80a0801b84febb9b3b3289665eb51 to your computer and use it in GitHub Desktop.
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
let rec insert (s: char list) (trie: trie) : trie = | |
let Node(children, hasEntry) = trie in match s with | |
| [] -> Node(children, true) | |
| first_char :: rest -> | |
let currentChild = if ChildList.mem first_char children | |
then (ChildList.find first_char children) | |
else empty | |
in | |
let newChild = insert rest currentChild in | |
let newChildren = ChildList.add first_char newChild children in | |
Node( | |
newChildren, | |
hasEntry | |
) | |
;; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment