[me] > A bit of polishing and I will post it. > def pmerge(seqs): res = [] while 1: for seq in seqs: if seq: break else: # all sequences are empty return res cands = [] for seq in seqs: # find merge candidates among seq heads if seq: cand = seq[0] for seq in seqs: if cand in seq[1:]: break else: # cand is not in any sequences' tail => constraint-free cands.append(cand) if not cands: raise "inconsistent precedences" next = cands[0] # append next to result and remove it from sequences res.append(next) for seq in seqs: if seq and seq[0] == next: del seq[0] def c3_cpl(cl): # compute class precedence list (mro) of class cl according to C3 inputs = [[cl]] for base in cl.__bases__: cpl = c3_cpl(base) inputs.append(cpl) inputs.append(list(cl.__bases__)) # C3: considers directly also inheritance list of cl return pmerge(inputs)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4