Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.8 collections: can't transpose a Seq of Sets #3397

Closed
scabug opened this issue May 6, 2010 · 3 comments
Closed

2.8 collections: can't transpose a Seq of Sets #3397

scabug opened this issue May 6, 2010 · 3 comments

Comments

@scabug
Copy link

scabug commented May 6, 2010

Welcome to Scala version 2.8.0.r21803-b20100505020119 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_19).

scala> Seq(Set(1,2,3),Set(4,5,6),Set(7,8,9)).map(_.toList).transpose
res0: Seq[Seq[Int]] = List(List(1, 4, 7), List(2, 5, 8), List(3, 6, 9))

scala> Seq(Set(1,2,3),Set(4,5,6),Set(7,8,9)).transpose
java.lang.IndexOutOfBoundsException: 1
	at scala.collection.mutable.ResizableArray$$class.apply(ResizableArray.scala:46)
	at scala.collection.mutable.ArrayBuffer.apply(ArrayBuffer.scala:44)
	at scala.collection.generic.GenericTraversableTemplate$$$$anonfun$$transpose$$1$$$$anonfun$$apply$$1.apply(GenericTraversableTemplate.scala:115)
	at scala.collection.generic.GenericTraversableTemplate$$$$anonfun$$transpose$$1$$$$anonfun$$apply$$1.apply(GenericTraversableTemplate.scala:114)
	at scala.collection.immutable.Set$$Set3.foreach(Set.scala:123)
	at scala.collection.generic.GenericTraversableTemplate$$$$anonfun$$transpose$$1.apply(GenericTraversableTemplate.scala:114)
	at scala.collection.generic.GenericTraversableTemplate$$$$anonfun$$transpose$$1.apply(GenericTraversableTemplate.scala:112)
	at scala.collection.Linear...
@scabug
Copy link
Author

scabug commented May 6, 2010

Imported From: https://issues.scala-lang.org/browse/SI-3397?orig=1
Reporter: @SethTisue

@scabug
Copy link
Author

scabug commented May 6, 2010

@paulp said:
(In r21826) Fixed bug in transpose, closes #3397, no review.

@scabug
Copy link
Author

scabug commented May 6, 2010

@harrah said:
This:

Seq(Seq(1,2), Seq(3), Seq(4,5)).transpose

produces this:

List(List(1, 3, 4), List(2, 5))

If I had to implement transpose, this is how I would do it if I couldn't just fail. I don't know if this behavior is ever actually desired, though, so perhaps transpose should throw an exception on irregular matrices. #3399 might be related.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant