I’m very new to OCaml and having a difficult time implementing a series of functions to build a T9 predictive text program. For example if my word is “Dog” - as an integer list would be [3;6;4]. I already have a pattern matching function to relate words to int lists. I’m using the data type trie to map numbers to the possible word outcomes possible:
type ('a, 'b) trie = Node of 'b list * ('a * ('a, 'b) trie) list
A trie with edges labelled with keys of type 'a and nodes labeled with lists of words of type 'b
I need to write a function with parameters trie and edge label that returns a trie at the end of the edge.
val trie_of_key : (’a, ’b) trie -> ’a -> (’a, ’b) trie = <fun>
How do I traverse the edges to arrive at a given node? Functional programming is still disorienting to me, so I am unsure of the recursive steps needed to arrive at the expected sub-trie.