You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
scala>List.separate(List.range(1,100000).map(Left(_)))
java.lang.StackOverflowError
at scala.List.foldRight(List.scala:1067)
at scala.List.foldRight(List.scala:1067)
at scala.List.foldRight(List.scala:1067)
at scala.List.foldRight(List.scala:1067)
at scala.List.foldRight(List.scala:1067)
at scala.List.foldRight(List.scala:1067)
at scala.List.foldRight(List.scala:1067)
at scala.List.foldRight(List.scala:1067)
at scala.List.foldRig...
Why is List.separate using foldRight? (Or maybe the question is: why is foldRight implemented using recursion that can lead to stack overflows?) It should probably use the same logic as Iterable.partition. Here's an implementation that would work:
@odersky said:
Tony, one other thing: In 2.8.0 lefts/rights/separate should be moved from
object List to object Either. More precisely, we are deprecating them in List, and will remove them afterwards. If you do the fix, can you already add the fixed versions to Either? Thanks! -- Martin
Why is List.separate using foldRight? (Or maybe the question is: why is foldRight implemented using recursion that can lead to stack overflows?) It should probably use the same logic as Iterable.partition. Here's an implementation that would work:
The text was updated successfully, but these errors were encountered: