下面列出的每個函數都按預期工作。 (除了最後一個) 我試圖讓to_list工作,我希望它返回的char listslist,但我到目前爲止,我只設法用簡單的prints實現其返回unit type trie = Trie of bool * (char * trie) list
let empty = Trie (false, [])
let explode wd = (*breaks up
實現我有一個TrieNode類定義如下: class TrieNode {
public:
map<char, TrieNode*> children;
bool isLeaf = false; // if node represents end of word
int wordCount = 0; // How many times the word appear
我想爲我的樹數據結構實現一個搜索功能。我很困惑如何正確地實現這一點,因爲我現在認爲我的邏輯似乎是正確的......儘管我仍然是這方面的初學者。如果有人可以看看我的功能,並建議在哪裏改進,那將不勝感激。主要接受大型文件,然後在其中搜索單詞以基本測試功能。現在它對於應該在特定對象中的單詞返回false。 例如錯誤消息 Error: jean-pierre is not in the spellchec