def make_banned_value_counter(banned_values, bindings): p = lambda expr : E.is_v(expr) and (bindings[E.unpack_v(expr)] in banned_values) def banned_value_counter(exprs): count = [0] f = make_counter(count) for expr in exprs: E.filter_walk(p, f, expr) return count[0] return banned_value_counter
def gather_atoms(atoms): vs = [] dos = [] for atom in atoms: (vs if is_v(atom) else dos).append(atom) return vs, dos
def p(expr): return is_v(expr) and unpack_v(expr) in new_labels