List.transpose is now tailrecursive. Removed format with Locale from StringAdd (it seems Locale is not supported on 1.4).

git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@13352 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
odersky 2007-11-26 19:20:12 +00:00
parent 47e8ed28e3
commit a9edd50e19
2 changed files with 9 additions and 10 deletions

View File

@ -354,9 +354,15 @@ object List {
* @param xss the list of lists
* @return the transposed list of lists
*/
def transpose[A](xss: List[List[A]]): List[List[A]] =
if (xss.head.isEmpty) List()
else (xss map (xs => xs.head)) :: transpose(xss map (xs => xs.tail))
def transpose[A](xss: List[List[A]]): List[List[A]] = {
val buf = new ListBuffer[List[A]]
var yss = xss
while (!yss.head.isEmpty) {
buf += (yss map (_.head))
yss = (yss map (_.tail))
}
buf.toList
}
/** Lists with ordered elements are ordered
implicit def list2ordered[a <% Ordered[a]](x: List[a]): Ordered[List[a]] = new Ordered[List[a]] {

View File

@ -18,13 +18,6 @@ final class StringAdd(self: Any) {
def +(other: String) = self.toString + other
/** Formats string according to given <code>locale</code> and
* <code>format</code> string. Formatstrings are as for
* <code>String.format</code> (@see java.lang.String.format)
*/
def format(locale: java.util.Locale, format: String): String =
String.format(locale, format, Array(self.asInstanceOf[Object]))
/** Formats string according to given <code>format</code> string.
* Format strings are as for <code>String.format</code>
* (@see java.lang.String.format).