collections
Last updated
Last updated
All of the collections come in 2 variants: immutable and mutable.
IndexedSeq | LinearSeq
There are mutable sets, and immutable sets. With immuable's methods returning new collection
.size
++
to concenate
.filter(x => x> 1)
remove any elem that X => bool returns false for
val sigTrackTopics = allTopics.filter(topic => topic.sigTrackAvailable())
Foreach
val stuff = Seq(thing1, thing2, thing3, thing4)stuff.foreach { thing => S3.delete(thing)}
better than while cuz list's require indexing(linear) less lines and ez parallelism
sideeffects only
.mkString
fancy to string with prefix, separator, suffix
conversions i.e .toSet
.map(p => p * 3)
applies transformation to every elem in collection
Arrays mutable, lists immutable otherwise same
Vector is a shallow tree with 32 children per node, logbase32 x bigO, usually better than list unless you are using head/tail
I Know its a linked list, but I want to index
Range
Can be represented as single obj with lower bound, upper bound, and step size
forall, exists, filter, map, zip, unzip, flatMap, sum, product, max, min
Functionally list of pairs