title: F# Iterate through sequence and call a function for each element of sequence
body: <p>I need to call a function for each element of a sequence, currently I have tried 
  Seq.iter and Seq.map but they return unit and 'a ->'c respectively and not Json like I need.</p>
  
  <p>I have tried </p>
  
  <pre><code>Seq.iter (fun _ (a,b,c,d) -&gt; iterateThroughMySequnce a b c d ()) sequence
  Seq.fold (fun _ (a,b,c,d) -&gt; iterateThroughMySequnce a b c d ()) sequence
  </code></pre>
  
  <p>but i am not getting the expected return type of Json. The code is needed below where the comment says "Something like this"</p>
  
  <p>Can anyone help Thanks</p>
  
  <pre><code>open Newtonsoft.Json.Linq
  
  type Json =
      | JObj of Json seq
      | JProp of string * Json
      | JArr of Json seq
      | JVal of obj
  
  let (!!) (o: obj) = JVal o
  
  let rec toJson = function
      | JVal v -&gt; new JValue(v) :&gt; JToken
      | JProp(name, (JProp(_) as v)) -&gt; new JProperty(name, new JObject(toJson v)) :&gt; JToken
      | JProp(name, v) -&gt; new JProperty(name, toJson v) :&gt; JToken
      | JArr items -&gt; new JArray(items |&gt; Seq.map toJson) :&gt; JToken
      | JObj props -&gt; new JObject(props |&gt; Seq.map toJson) :&gt; JToken
  
  let sequence = seq { yield "USD", 12.36M, 156.32M, 18.23M
                       yield "JPY", 13.36M, 564.32M, 17.23M 
                       yield "GBP", 14.36M, 516.32M, 120.23M }
  
  let iterateThroughMySequnce a b c d () =
      JObj [JProp("CurrencyCode", !! a);
            JProp("TotalPerCurrencyBeforeExchange", !! b); 
            JProp("ExchangeRate", !! c);
            JProp("TotalPerCurrencyAfterExchange", !! d)];
  
  let k =
      JObj [
          JProp("InvoiceNumber", !! "13456789");
          JProp("InvoiceDate", !! "21/12/2015");
          JProp("InvoiceCurrency", !! "USD");
          JProp("InvoiceProfitMargin", !! 2.3);
          JProp("InvoicePaymentCurrencyToEuroExchangeRate", !! 0.8658745M);
          JProp("InvoicePeroid", !! "01/01/2015 00:00:00 - 01/02/2015 23:59:59");
          JProp(
              "Transaction", 
                  JArr [
                      //Something like this
                      Seq.iter (fun (a,b,c,d) -&gt; iterateThroughMySequnce a b c d ()) sequence
                  ])
          JProp("TransactionForPeroid", !! 254584.00M);
          JProp("InvoicingAmountWithProfitMarginApplied", !! 8452.01M);
          JProp("InvoicingAmountWithProfitMarginAppliedInEuro", !! 7851.28);
      ]
  
  let json = toJson k 
  </code></pre>