diff --git a/filter2.py b/filter2.py new file mode 100644 index 0000000..4af8680 --- /dev/null +++ b/filter2.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python +"""Plus rapide""" + +import pyparsing + +def simplify(l): + if not isinstance(l, list): + return l + if len(l) == 1: + return simplify(l[0]) + else: + return [simplify(i) for i in l] + +def toprefix(l): + if not isinstance(l, list): + return l + op=l[1] + args=[toprefix(i) for i in l if i!=op] + return [op]+args + +def prioritize(l): + if not isinstance(l, list): + return l + l=simplify(l) + for c in ['!=', '=', '&', '|']: + i=0 + while i