All pastes #364857 Raw Edit

Unnamed

public text v1 · immutable
#364857 ·published 2007-02-20 13:14 UTC
rendered paste body
def cond_to_for(expr):
	expr=filter(lambda a:a!=' ',expr)
	a=[""]
	for i in expr:
		if i=='?' or i==':':
			a.append("")
		else:
			a[-1]+=i
	def cond_to_for_(cond_,true_,false_):
		return "(["+true_+" for i in ["+cond_+"] if i]+["+false_+"])[0]"
	return cond_to_for_(a[0],a[1],a[2])