562 @verb #7165:"merge" this none this rxdo #7165 @program #7165:"merge" this none this "Takes, as args, a list of lists such that list[foo] => parents(foo), the object for which the list is to be made, followed by the precedence lists for each of the object's parents." "Returns the precedence list for the object." {class_heir, object, @prp} = args parents = class_heir[object] out = {object} p_lists = parents ? {parents, @prp} | {} while (p_lists) possibilities = {} for x in (p_lists) possibilities = setadd(possibilities, x[1]) endfor oks = {} while poss (possibilities) poss = possibilities[1] for p_list in (p_lists) if (poss in p_list > 1) possibilities = listdelete(possibilities, 1) continue poss endif endfor oks = setadd(oks, poss) possibilities = listdelete(possibilities, 1) endwhile if (length(oks) == 1) out = {@out, oks[1]} elseif (!oks) raise(E_NONE, "HELP!! No possibilities!!!") else p = class_heir[out[$]] for x in (oks) if (x in p) out = {@out, x} break endif endfor endif for i in [1..length(p_lists)] if (p_lists[i][1] == out[$]) p_lists[i] = listdelete(p_lists[i], 1) endif endfor while (p_lists != (p_lists = setremove(p_lists, {}))) endwhile endwhile return out . 0