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
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:
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
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
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
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
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)
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
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
When I evaluate a for in Scala, I get an immutable IndexedSeq (a collection with array-like performance characteristics, such as efficient random access):