Tuesday 15 July 2014

F#: InvalidOperationException: The input sequence has an insufficient number of elements? -


I have functions that return the order of records, in that function, I started building a list with empty dummy record I'm (probably a better way of doing this) because I need to submit records, so I have a blank record with "Pump the Pump" here my code is:

  Integrate ( Somethings: seq & lt; some & gt;) = ineffectual results = resizeArray () accumulates volatile Some = {Foo = ""; Bar = ""; For socks = 0;} do anything, if s.Foo = something stored. Foo & amp; S.Bar = Accumulated something. Some of the later & lt; - {Foo = s.Foo; Bar = s.Bar; Calculation = s.Count + Accumulated something. Calculation} and results. Add (some cached) accumulated something & lt; - e Results | & Gt; Seq.cast | & Gt; Seq.skip 1 If you have a way to make this better, then I am all ears (I am still thinking methodically), but I can answer this specific question. I still take interest in Later in my code, I try to print the list:  
  somethings | & Gt; Seq.iter (fun -> gt; printfn "% A" s)   

It works fine when it comes to the list, but if the list is empty and the only record blank starter in the list Is recorded, then this line fails with the message invalid operation exception with the message is an inadequate number in the input order element?

Why does this happen and how can I fix it?

The problem occurs when somethings is an empty list.

In this case, the result is empty and calling Seq.skip 1

I think an elegant solution

  will change the match result to the last line. 0 - & gt; Results | & Gt; Seq.cast | _ - & gt; Results | & Gt; Seq.cast | & Gt; Seq.skip 1    

No comments:

Post a Comment