fold (\\${x} ${element} -> ${x} + ${element}) ${acc} ${collection}

      Haskell language logo

      Haskell public recipes

      The fold function takes two arguments: the value of x and the value of element. The function combines these two values and returns the result.

      The first argument is interpreted as a function that takes one argument, which is the value of x. The function then takes the value of element and combines it with the value returned from the function that was passed as the first argument. This results in the return value of the fold function.

      The second argument is the accumulator. This is a variable that is used to keep track of the result of the function. The accumulator is set to the value of ${acc} after the function is run. The ${acc} variable is then multiplied with the value of ${collection}.

      Shortcut: fold


        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.