From 368d511247d5be7bd3ae8a1ce4a5be45fd3dcceb Mon Sep 17 00:00:00 2001 From: buraq Date: Tue, 8 Jun 2004 12:11:59 +0000 Subject: NodeSeq comprehension methods --- sources/scala/xml/NodeSeq.scala | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'sources') diff --git a/sources/scala/xml/NodeSeq.scala b/sources/scala/xml/NodeSeq.scala index 9909167aeb..73d15843ea 100644 --- a/sources/scala/xml/NodeSeq.scala +++ b/sources/scala/xml/NodeSeq.scala @@ -42,4 +42,19 @@ class NodeSeq( theSeq:Seq[Node] ) extends Seq[Node] { override def toString() = theSeq.elements.foldLeft ("") { (s:String,x:Node) => s + x.toString() } + + private var _asList:List[Node] = null; + def asList = { + if (_asList == null ) _asList = elements.toList; + _asList + } + + def map( f:Node => Node ):NodeSeq = { + new NodeSeq( asList map f ) + } + + def flatMap( f:Node => NodeSeq ):NodeSeq = { + new NodeSeq( asList flatMap { x => f(x).asList }) + } + } -- cgit v1.2.3