title: Function chaining in Python
body: <p>On <a href="https://www.codewars.com/" rel="noreferrer">Codewars.com</a> I encountered the following task:</p>
  <blockquote>
  <p>Create a function <code>add</code> that adds numbers together when called in succession. So <code>add(1)</code> should return <code>1</code>, <code>add(1)(2)</code> should return <code>1+2</code>, ...</p>
  </blockquote>
  <p>While I'm familiar with the basics of Python, I've never encountered a function that is able to be called in such succession, i.e. a function <code>f(x)</code> that can be called as <code>f(x)(y)(z)...</code>. Thus far, I'm not even sure how to interpret this notation.</p>
  <p>As a mathematician, I'd suspect that <code>f(x)(y)</code> is a function that assigns to every <code>x</code> a function <code>g_{x}</code> and then returns <code>g_{x}(y)</code> and likewise for <code>f(x)(y)(z)</code>.</p>
  <p>Should this interpretation be correct, Python would allow me to dynamically create functions which seems very interesting to me. I've searched the web for the past hour, but wasn't able to find a lead in the right direction. Since I don't know how this programming concept is called, however, this may not be too surprising.</p>
  <p>How do you call this concept and where can I read more about it?</p>