Thursday, 15 May 2014

list - How to take sublist without first and last item with F#? -


I sorted the list of integer values:

  two ls = [1. .4]  

How do I get a sublist without the first and last element? (In the most optimal route)

Expected Result is [2; 3] .

It is with me till now, and yes, it is working, but in my opinion this is not the best way.

  [1. 4] | & Gt; List tail. & Gt; List.reve | & Gt; List tail. & Gt;  
"post-text" itemprop = "text">

This is a way:

  Rec Trim LS ACC = Match L S, with ACC [], _ - & gt; ACC | H: [], ACC - & gt; List REV ACC | H :: n :: t, [] - & gt; Trim t [n] | H :: t, acc - & gt; Trim T (H: ACC) let's reslt = trim ls []  

No comments:

Post a Comment