Haskell public recipes

    This code calculates the sum of the elements in the collection, and then folds the result into the accumulator. The foldl function takes a function that takes two inputs: the current element and a default value. The function is called with the current element and the default value, and the result is returned to the foldl function. The Foldl function then uses the + operator to add the default value to the current element, and returns the result.

    Shortcut: foldl

    foldl (\\${x} ${element} -> ${x} + ${element}) ${acc} ${collection}
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.