Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private def tr[T](pf:PartialFunction[Elem,Elem]): T=>T ={
- case e:Elem if pf.isDefinedAt(e) => pf(e).asInstanceOf[T]
- case e:Elem =>{
- val xs=e.child.map(tr(pf))
- val(a,b)=e.child.zip(xs).partition(x=>x._1==x._2)
- (if(b.isEmpty) e else e.copy(child=xs)).asInstanceOf[T]
- }
- case x => x
- }
Add Comment
Please, Sign In to add comment