In functional programming languages, the most primitive/basic operation on a collection is the homomorphism map
; it is (roughly) Collection[A] -> (A->B) -> Collection[B]
The Rust collections don't seem to support this. I suppose that's because they are mutable collections; if you're already using mutable collections an in-place update is more efficient.
Is there a separate "immutable collections" library (like with Scala) that I missed?
What about an "in-place map" operation that uses an A->B
to mutate a Collection[A]
into a Collection[B]
(unlike ML and Haskell it's actually possible do to this safely because of affine types!) Or even the special case where A=B
and the in-place map takes an A->A
?
It's hard to use search engines to answer this question because all the hits involve "map" the noun (as in HashMap
).