[pyar] [OT] - Checkeando parentesis balanceados.
Roberto Alsina
ralsina en netmanagers.com.ar
Vie Jun 18 13:59:47 ART 2010
On Friday 18 June 2010 13:53:45 Roberto Alsina wrote:
> def balanceado(t):
> t1=[(-1)**s.find(c) for c in t]
> if any (map (lambda x: x<0, [sum (t1[:i]) for i in
> range(len(t1))])) or t1[-1]:
> return False
> return True
Podría hacer un
lambda balanceado t: return not (any (map (lambda x: x<0, [sum (t1[:i]) for i
in range(len(t1))])) or t1[-1])
pero me pareció demasiado horrible ;-)
More information about the pyar
mailing list