diff options
author | michelou <michelou@epfl.ch> | 2005-09-15 16:28:50 +0000 |
---|---|---|
committer | michelou <michelou@epfl.ch> | 2005-09-15 16:28:50 +0000 |
commit | dc4422b5c667a8b460891281ecfbf366df42f3b7 (patch) | |
tree | 8754b7e21501f63f9afdcb3851be6bc665b8202f /sources | |
parent | 9e3c3c97318f8c567ff8e6cec0c8409ad95fce2c (diff) | |
download | scala-dc4422b5c667a8b460891281ecfbf366df42f3b7.tar.gz scala-dc4422b5c667a8b460891281ecfbf366df42f3b7.tar.bz2 scala-dc4422b5c667a8b460891281ecfbf366df42f3b7.zip |
- updated code for current Scala XML library :-(
Diffstat (limited to 'sources')
-rw-r--r-- | sources/examples/fors.scala | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/sources/examples/fors.scala b/sources/examples/fors.scala index dc7b8094b2..6c969d3519 100644 --- a/sources/examples/fors.scala +++ b/sources/examples/fors.scala @@ -41,45 +41,48 @@ object fors { type Lst = List[Any]; + val prefix = null; + val scope = TopScope; + val books = List( - Elem("", "book", e, - Elem("", "title", e, + Elem(prefix, "book", e, scope, + Elem(prefix, "title", e, scope, Text("Structure and Interpretation of Computer Programs")), - Elem("", "author", e, + Elem(prefix, "author", e, scope, Text("Abelson, Harald")), - Elem("", "author", e, + Elem(prefix, "author", e, scope, Text("Sussman, Gerald J."))), - Elem("", "book", e, - Elem("", "title", e, + Elem(prefix, "book", e, scope, + Elem(prefix, "title", e, scope, Text("Principles of Compiler Design")), - Elem("", "author", e, + Elem(prefix, "author", e, scope, Text("Aho, Alfred")), - Elem("", "author", e, + Elem(prefix, "author", e, scope, Text("Ullman, Jeffrey"))), - Elem("", "book", e, - Elem("", "title", e, + Elem(prefix, "book", e, scope, + Elem(prefix, "title", e, scope, Text("Programming in Modula-2")), - Elem("", "author", e, + Elem(prefix, "author", e, scope, Text("Wirth, Niklaus"))) ); def findAuthor(books: Lst) = - for (val Elem(_, "book",_,book @ _*) <- books; - val Elem(_, "title",_,Text( title )) <- book; + for (val Elem(_, "book", _, scope, book @ _*) <- books; + val Elem(_, "title", _, scope, Text(title)) <- book; (title indexOf "Program") >= 0; - val Elem(_, "author",_,Text( author )) <- book) yield author; + val Elem(_, "author", _, scope, Text(author)) <- book) yield author; - for (val Elem(_, "book", _, b @ _*) <- books; - val Elem(_, "author", _, Text( author )) <- b; + for (val Elem(_, "book", _, scope, b @ _*) <- books; + val Elem(_, "author", _, scope, Text(author)) <- b; author startsWith "Ullman"; - val Elem(_, "title", _,Text( title )) <- b) yield title; + val Elem(_, "title", _, scope, Text(title)) <- b) yield title; removeDuplicates( - for (val Elem(_, "book", _, b1 @ _* ) <- books; - val Elem(_, "book", _, b2 @ _*) <- books; + for (val Elem(_, "book", _, scope, b1 @ _* ) <- books; + val Elem(_, "book", _, scope, b2 @ _*) <- books; b1 != b2; - val Elem(_, "author",_, Text( a1 )) <- b1; - val Elem(_, "author",_, Text( a2 )) <- b2; + val Elem(_, "author", _, scope, Text(a1)) <- b1; + val Elem(_, "author", _, scope, Text(a2)) <- b2; a1 == a2) yield Pair(a1, a2)); def removeDuplicates[a](xs: List[a]): List[a] = |