title: Resolving of lambda function
body: <p>this is from an examination paper online, but it has no worked solutions. I have trouble understanding why and how the answer is 32 from this code, like how is the priority of resolving brackets like. I personally resolved the following print expression to foo(bar)(8) before getting stuck, as foo should take the first parameter to be a value preferably and 2nd parameter from the lambda to be a function, this case, bar and 8 are at different places.</p>
  
  <pre><code>    def bar(x):
          return lambda y: x(x(y))
  
      def foo(y):
          return lambda x: x(y)
  
      print((foo(bar)(bar)(lambda x:x*2)(2)))
  </code></pre>
  
  <p>I would appreciate a detailed answers or any sites where I can build my foundation on resolving lambdas like this. Learning this on my own and I dont really have a good understanding on this topic. Thanks.</p>