title: How to convert a seemingly self-calling F# lambda to C#?
body: <p>I'm trying to convert some F# code to C# but I don't understand this particular block:</p>
  
  <pre><code>let GetItems = asyncResult {
      let! items = StaticClass.getItems
      return 
          items
          |&gt; AsyncSeq.map (fun item -&gt; 
              fun handleItem -&gt; asyncResult {
                  let! itemCanBeRemoved = handleItem item|&gt; AsyncResult.mapError HandleItemError
                  // some code removed for clarity
              })
   }
  </code></pre>
  
  <p>My attempt to convert this is:</p>
  
  <pre><code>public static async Task&lt;IEnumerable&lt;T&gt;&gt; GetItems&lt;T&gt;() where T : Item
  {
      var items = await StaticClass.GetItems();
  
      var tasks = new List&lt;Task&gt;();
      foreach (var item in items)
      {
          bool itemCanBeRemoved;
          if (itemCanBeRemoved)
          {
              // do something
          }
          else
          {
              // do something else
          }
      }
  
      await Task.WhenAll(tasks);
  
      return items;
  }
  </code></pre>
  
  <p>Assuming my conversion is on the right track, I don't understand how the handleItem func is defined and then invoked within its own implementation block. Can someone please explian what handleItem is doing and how it invokes itself?</p>