// map: index of opening bracket -> index of closing bracket static Map getBracketMapC(L tok) { new TreeMap map; new L stack; int n = l(tok); for i to n: { if (getBracketMapC_opening.contains(tok.get(i))) stack.add(i); else if (getBracketMapC_closing.contains(tok.get(i))) { if (!empty(stack)) map.put(liftLast(stack), i); } } ret map; } static L getBracketMapC_opening = ll("{", "("); static L getBracketMapC_closing = ll("}", ")");