Passing list values to a function

You did not specify what the calculate_percentage function should do and that is quite important.

But if you want it to return a single value, you want to look at Enum.reduce. A reduce is one of the most fundamental operations in functional programming so it’s useful to learn it. With it, you can reduce an input value to an output value. For example you can reduce a list into a single value (but the output can be anything, and it can even be a list).

Without knowing what your function does, you probably want something like:

Enum.reduce(students, 0, fn student, accumulator ->
  calculate_percentage(accumulator, student)
end)

The accumulator is the value that has been accumulated during the processing of the input and in every call, you need to return the updated value of the accumulator, which will be given with the next value from the input. The final value of the accumulator is the return value of the reduce.

If this does not answer your question, can you elaborate on what calculate_percentage should do?