Go to the first, previous, next, last section, table of contents.


childOf?

Function: childOf? { kid mom -> tOrNil }
file: cdt.t
package: muf
status: alpha

True if mom can be reached from kid by following zero or more kid$s.parents pointers. If kid$s.parents is a vector, then all pointers in the vector are checked recursively.

This function is hand-assembled into the db by cdt.t because .lib.muf.]doSignal needs it, and we want .lib.muf.]doSignal functioning as soon as the server starts executing code.

The source is effectively

: childOf2? -> n -> mom -> kid
    do{
        mom kid = if t n return fi
        n 0 = if nil n return fi
        n 1 - -> n
        kid$s.parents -> parents
        parents vector? if
            parents foreach i kid do{
                kid mom n childOf2? -> n if t n return fi
                n 0 = if nil n return fi
                n 1 - -> n
            }
            nil n return
        else
            parents -> kid
        fi
    }
;
: childOf? 512 childOf2? pop ;

where the limit of checking 512 parents is to keep accidental or deliberate parenting loops from hanging childOf? and hence .lib.muf.]doSignal in an infinite loop.

See section ]doSignal.


Go to the first, previous, next, last section, table of contents.