Hi,
I have an assignment to do and I can't figure out how to do one question. Here is what I have to do:
" Write a function which collects all elements in the tree T which satisfies the property p and returns it. Traverse the tree in inorder. Find all elements in BST satisfying f using success continuations.".
I did the following:
datatype 'a tree =
Empty | Node of (int * 'a) * 'a tree * 'a tree
fun find_all f Empty cont = cont()
| find_all f (Node(x, l, r)) cont = if (f x) then find_all (f l (fn x => x::cont())) @ find_all (f r (fn x => x::cont()))
else find_all (f l (fn () => cont())) @ find_all (f r (fn () => cont()));
I don't understand why it's not working...
Thank you very much for your help!