scala-collections
Scala: Why does Seq.contains take an Any argument, instead of an argument of the sequence type?
So for example why does List(1,2,3,4).contains(\"wtf\") even compile? Wouldn\'t it b开发者_高级运维e nice if the compiler rejected this?Lots of interesting answers, but here\'s my own theory: if conta[详细]
2023-01-15 06:27 分类:问答Scala collection filter by type
im new to scala and ran into the following problem: I want to get a subcollection of an existing collection that only contains elements of a specific type. The following works:[详细]
2023-01-14 23:11 分类:问答What type to use to store an in-memory mutable data table in Scala?
Each time a function is called, if it\'s result for a given set of argument values is not yet memoized I\'d like to put the result into an in-memory table. One column is meant to store a result, other[详细]
2023-01-14 04:43 分类:问答What's a good and functional way to swap collection elements in Scala?
In a project of mine one common use case keeps coming up. At some point I\'ve got a sorted collection of some kind (List, Seq, etc... doesn\'t matter) and one element of this collection. What I want t[详细]
2023-01-09 09:38 分类:问答Scala collection: totally unpredictable behaviours
Have been pretty frustrated by Scala 2.8 collection behaviours. Here\'s the problem: I\'m creating a Sudoku board. I\'m labelling the cells from A1 to I9 (the letters being the rows and the digits bei[详细]
2023-01-08 15:30 分类:问答Can I "pimp my library" with an analogue of TraversableLike.map that has nicely variant types?
Suppose I want to add functionality like map to a Scala List, something along the lines of list mapmap f, which applies the function f to each element of list twice. (A more serious example might be i[详细]
2023-01-06 15:12 分类:问答Creating lists and sets in Scala: What do I actually get?
If I create a Set in Scala using Set(1, 2, 3) I get an immutable.Set. scala> val s = Set(1, 2, 3) s: scala.collection.immutable.Set[Int] = Set(1, 2, 3)[详细]
2023-01-05 10:00 分类:问答What is the fastest way to sum a collection in Scala
I\'ve tried different colle开发者_Go百科ctions in Scala to sum it\'s elements and they are much slower than Java sums it\'s arrays (with for cycle). Is there a way for Scala to be as fast as Java arra[详细]
2023-01-04 23:41 分类:问答Why does Iterator have a contains method but Iterable does not, in Scala 2.8?
I would like 开发者_如何学JAVAto call \'contains\' on my Iterables :-)The reason Iterable does not have a contains method is because the way it is defined can have direct consequences on variance. Bas[详细]
2023-01-01 21:56 分类:问答Collection type generated by for with yield
When I evaluate a for in Scala, I get an immutable IndexedSeq (a collection with array-like performance characteristics, such as efficient random access):[详细]
2023-01-01 12:49 分类:问答