I have a need to extract the individual items from an Enum.reduce function but I get is the single value from the acc.
Here is the sample code:
defmodule Demo do
def add_sequence_number(business_card) do
business_card
|> String.split("\n")
|> Enum.reduce(1, fn (x, acc) -> IO.inspect "#{acc}$#$#{x}"; acc + 1 end)
end
end
business_card = """
Bruce Waine,Batman
Bat cave
Gotham City, NY 12345
987.123.5984
Gotham Security Services Co
Crime fighter
Wonder Woman
"""
new_card = Demo.add_sequence_number(business_card)
IO. puts "\nthis is the result: #{new_card}\n"
here is a screen shot of the result:
what I need is the array from the inner reduce function but I am getting is the result of 10 and I need to access the list as in the image.
any tips, thank you