やるべき課題があり、1 つの質問のやり方がわかりません。これが私がしなければならないことです:
プロパティ p を満たすツリー T のすべての要素を収集して返す関数を作成します。ツリーを順番にトラバースします。成功継続を使用して、f を満たす BST 内のすべての要素を検索します。
私は次のことをしました:
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()));
なぜ機能しないのか理解できません...