26
votes

What is the easiest way to count the number of elements in a sequence in F#?

5

5 Answers

52
votes

Use Seq.length

Returns the length of the sequence

9
votes
open System.Linq

mySeq.Count()
7
votes

...and hope it's finite

6
votes

FYI, if you search the library docs for Seq for "-> int" you'll find this rather quickly.

5
votes

you can use Seq.length