Guest User

Untitled

a guest
Feb 18th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. private def tr[T](pf:PartialFunction[Elem,Elem]): T=>T ={
  2. case e:Elem if pf.isDefinedAt(e) => pf(e).asInstanceOf[T]
  3. case e:Elem =>{
  4. val xs=e.child.map(tr(pf))
  5. val(a,b)=e.child.zip(xs).partition(x=>x._1==x._2)
  6. (if(b.isEmpty) e else e.copy(child=xs)).asInstanceOf[T]
  7. }
  8. case x => x
  9. }
Add Comment
Please, Sign In to add comment