Equilibrium Index Implementation I have come up with a solution to the equilibrium index problem with help from the answers off here:

val in = Stream(-7, 1, 5, 2, -4, 3, 0)
val sum = in.scan(0)(_ + _)
val hash = (in zip sum) map { case (e, lsum) =&gt; 2*lsum + e }
val target = sum.last
hash.zipWithIndex.collect { case (e, i) if e == target =&gt; i }


It's unfortunate that I have to traverse through the whole stream again to get target.

Are there any possible improvements?
hash is poorly named, I think, but that's a minor detail.

Your solution is inefficient because you are doing it all with sequences.  Have you considered that zipWithIndex is also duplication?  You've already worked through the input stream once - each time you calculated the current sum, you could (had you wanted) have been aware of your position in the list?  You're duplicating work.

More efficient solution (in that there will only be one traversal) is to fold, not scan and to build a map (for quick extraction of results).

Fold over the input stream, with a seed of (0, 0, Map[Int, List[Int]]).  The first value is an index accumulator, the second is a sum accumulator and the nature of the map will become obvious shortly.  The function you apply to each fold iteration should


Add the current stream item to twice the accumulated sum.
If the resulting number is not a key in the map, insert `list(index-accumulator-value)' into the map with that newly-calculated number as a key
If the resulting number is already a key, add index-accumulator-value to the list stored under that key (important: cons it to the list, do not append).
Increment the index accumulator by one.
Add the current stream item to the accumulated sum.
Return (index-accumulator, sum-accumulator, map)


Once the fold has completed, you will have 


The size of the stream (which you don't need)
The sum of the stream (which you do)
A map.


If the map contains a key which is equal to the sum of the stream, the value associated with that key will be a list of all equilibrium indices, sorted in reverse order.  If there is no such key, there were no equilibrium indices.


Minimal traversal
No filtering necessary
Rapid access to final result because Map


Done.

Annoyed that the final result is in reverse order?  Reversing one final list is cheap compared to appending to each list in the map, every time.

Note that you can dispense with having to manage the index-accumulator by folding over in.zipWithIndex