Skip to main content
100%

Gist b64124620bd851544b8e9e87b16370e8

✓ Published0🌍 Public
Aakeshavan
Last edited Sep 30, 2016
Created on Sep 30, 2016

This Jupyter notebook demonstrates how to define a curried `multiadder` function in Python, where `multiadder(n)` returns a chain of functions that each accept one argument and accumulate a sum. The code shows two implementations: a first pass using a dummy total variable, and a refined version that returns nested functions to handle the summation. Example calls like `multiadder(5)(1)(1)(1)(1)(1)` output `5`, and `multiadder(2)(4)(5)` returns `9`, illustrating the incremental function-returning behavior. The notebook uses standard Python 2 syntax, with code cells and Markdown explanations, and outputs results directly as text.

AI-generated description

Similar vizzes