3 ms·
You CAN create mutable data structures. This can be very useful LOCALLY. But then turn it into an immutable data structure as soon as you return it. Example:
by DannyB2 7y ago
You CAN create mutable data structures. This can be very useful LOCALLY. But then turn it into an immutable data structure as soon as you return it.
Example: a sieve function for primes. Pass it a range of n1 to n2. It seives that range, say from (1 million) to (1 million plus 100,000). It could use an efficient mutable data structure locally. Then return an immutable result. Especially since the result has no reason to EVER be mutable again. You're not going to find more or less primes within that range.