In the following code I am trying to set a mutable variable len to the length of a list.

How can I do this?

let DoPairs (dl:seq<myHash>) (cnt:int) :unit =

if cnt > 1 then

dl |> Seq.pairwise

|> Seq.iter (fun el -> Determine (fst el) (snd el))

InsertNs LastHash firstYr LastHash.yr

else

dl |> Seq.iter(fun mh -> InsertNs mh firstYr LastHash.yr)

let mutable len = 0

let grouping (data:seq<myHash>) :unit =

data |> Seq.toList

|> List.length (fun lstlen -> DoPairs data lstlen.Length)

DoPairs data len

By on 7/22/2010 11:13 AM ()

How about always making sure your sequence contains at least 2 elements?
You can keep a counter where you generate it and, if you have only one, you add another that is neutral to the Determine function (that is, that 'makes' Determine do what you want in the case of 1 element).

But you solution with 2 cases looks OK too.

By on 7/23/2010 2:22 AM ()

thanks.

By on 7/26/2010 11:00 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper