Flow.reduce throws an error

Hi Everyone,

I am learning Elixir and i am trying to compile this program but not with success.

Goal: TO sum the list parallely using Flow

defmodule ParallelProcessing do
use Flow
def process_numbers(numbers) do
numbers
|> Flow.reduce(fn → 0 end, &(&1+&2))
|>Enum.to_list()
end
end
numbers = 1…10
result= ParallelProcessing.process_numbers(numbers)
IO.inspect(result)

But the following error is thrown
08:57:35.842 [error] GenServer #PID<0.183.0> terminating
** (Protocol.UndefinedError) protocol Enumerable not implemented for 110 of type Integer, Flow attempted to convert the stage accumulator into events but failed, to explicit convert your current state into events use on_trigger/2

I am using Flow version 1.2.4
Elixir version: 1.13.4, Erlang/OTP 25[erts-13.0.4]

All this is being run from Debian and hence these versions (without using asdf)

Can you guys help please
Sincerely,
Suds

Please, next time format your code with triple backticks. The error you get is pretty self explanatory, 110 is not enumerable.Flow.reduce/3 returns a single integer and you call Enum.to_list/1 with it. The integer doesn’t implement the Enumerable protocol.

Thanks a lot.
Can you help me to extract this sum from Flow.reduce.
Sincerely,
Suds

It’s already there as Flow.reduce/3 returns it.

The Problem i face is that when i try to print it the actual value is not displayed. The internal Flow structure with consumers and producers are displayed. I print the value using IO.inspect