1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
\DOC find_path
\TYPE {find_path : (term -> bool) -> term -> string}
\SYNOPSIS
Returns a path to some subterm satisfying a predicate.
\DESCRIBE
The call {find_path p t} traverses the term {t} top-down until it finds a
subterm satisfying the predicate {p}. It then returns a path indicating how to
reach it; this is just a string with each character interpreted as:
\begin{{itemize}}
\item {"b"}: take the body of an abstraction
\item {"l"}: take the left (rator) path in an application
\item {"r"}: take the right (rand) path in an application
\end{{itemize}}
\FAILURE
Fails if there is no subterm satisfying {p}.
\EXAMPLE
{
# find_path is_list `!x. ~(x = []) ==> CONS (HD x) (TL x) = x`;;
Warning: inventing type variables
val it : string = "rblrrr"
}
\SEEALSO
follow_path, PATH_CONV.
\ENDDOC
|