diff options
author | buraq <buraq@epfl.ch> | 2004-06-08 12:11:59 +0000 |
---|---|---|
committer | buraq <buraq@epfl.ch> | 2004-06-08 12:11:59 +0000 |
commit | 368d511247d5be7bd3ae8a1ce4a5be45fd3dcceb (patch) | |
tree | 0d38ddc92305cabe1943b8d6c9a66458aee2e599 /sources | |
parent | b0b5b5fc12aab119453520185414ebf31dfdcc66 (diff) | |
download | scala-368d511247d5be7bd3ae8a1ce4a5be45fd3dcceb.tar.gz scala-368d511247d5be7bd3ae8a1ce4a5be45fd3dcceb.tar.bz2 scala-368d511247d5be7bd3ae8a1ce4a5be45fd3dcceb.zip |
NodeSeq comprehension methods
Diffstat (limited to 'sources')
-rw-r--r-- | sources/scala/xml/NodeSeq.scala | 15 |
1 files changed, 15 insertions, 0 deletions
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 }) + } + } |