Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Since the inputs to the continuation are the postfix of words, you know that after the next continuation is called, the result has to be closer to the list of words in the trie and still be the postfix of the words. You can use this to determine that what the continuation is supposed to do is prepend the next letter up the trie (given a char list list, it'll prepend a char to every char list in the list).</p> <pre><code>fun words_in_trie Empty cont = cont[] </code></pre> <p>If the trie you're passing is <code>Empty</code>, then you have one word in that trie, and that's an empty string. The result you want is <code>[""]</code>. Recall that the last continuation converts every <code>char list</code> in the list to a <code>string</code>, so in order to get that result, you need to pass it a list with an empty <code>char list</code> for it to convert.</p> <pre><code>|words_in_trie (Node(c,rl)) cont = (all_words rl (fn r=&gt; cont(c::r))) </code></pre> <p>Recall: the type of the continuation is <code>char list list -&gt; 'a</code>. <code>c</code> is a <code>char</code>, so it can't be prepended to <code>r</code>, which is of type <code>char list list</code>.</p> <p><code>all_words</code> returns a list of all words contained in the list of tries <code>rl</code>, to which you want to apply the continuation (which prepends all chars up the trie). You have to build up the continuation so that in addition to prepending all chars from the nodes up the trie, it also prepends the <code>char</code> <code>c</code> from the current node. What you're looking for is something like this:</p> <pre><code>fn x =&gt; cont (map (fn y =&gt; c::y) x) </code></pre> <p>The above prepends <code>c</code> to every <code>char list</code> in the list, then passes it on to the next continuation, which goes on to prepend the next <code>char</code>.</p> <p>Your <code>all_words</code> function looks fine to me.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload