Stream.transform/4

defmodule Stream do
  def transform(stream, start_fun, fun, after_fun)
end

Transforms an existing stream with function-based start and finish.

The accumulator is only calculated when transformation starts. It also allows an after function to be given which is invoked when the stream halts or completes.