F# take subsequence of a sequence

半腔热情 提交于 2019-12-12 04:53:00

问题


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

.


回答1:


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]


来源:https://stackoverflow.com/questions/34093543/f-take-subsequence-of-a-sequence

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!