For my assignment I have to do two functions with the type:
wt: trie -> (char list list -> ’a)-> ’a
aw: trie list -> (char list list -> ’a)-> ’a
but what I have is this and was wondering if it was the same thing:
wt: 'a trie -> ('a list list -> ’a list list)-> ’a list list
aw: 'a trie list -> ('a list list -> ’a list list)-> ’a list list
This is my function:
datatype ’a trie = Node of ’a * (’a trie) list | Empty
fun words_in_trie Empty cont = cont [[]]
| words_in_trie (Node (c, lis)) cont = all_words lis (fn j => map (fn y => [c]@y) j)
No, those are not the same. For each of them, look at the second parameter, the function. Your assignment says:
Your version says:
Okay, so let’s assume that in your function,
'aischar. That means that we can rewrite it toWhich is different from what the assignment says. Of course, the
'ain the assignment could in theory be achar list list, but when it’s specified as'a, that probably means that your teachers want it to be generic.