Kote
Kote

Reputation: 723

F# take subsequence of a sequence

I need to define a function, which takes a sequence enter image description here and integers i and n as parameters and returns sub list or sub sequence of this seq, defined as followed:

enter image description here .

Upvotes: 0

Views: 192

Answers (1)

TheInnerLight
TheInnerLight

Reputation: 12184

You can write:

let subSeq i n = Seq.skip i >> Seq.take n

Which is used, e.g.:

let result = subSeq 5 10 [0..20]

Upvotes: 4

Related Questions