(define goal? S -> (= (sum S) 27)) (define depth State F G? -> (depth-help [State] F G?)) (define depth-help [State | _] _ G? -> State where (G? State) [State | _] F G? <- (depth-help (F State) F G?) [_ | States] F G? -> (depth-help States F G? ) _ _ _ -> (fail)) (depth [] (fn f) (fn goal?))