F#取序列的子序列 [英] F# take subsequence of a sequence

查看:112
本文介绍了F#取序列的子序列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要定义一个函数,该函数需要一个序列 并以整数in作为参数,并返回此seq的子列表或子序列,定义如下:

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:

推荐答案

您可以编写:

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

使用哪个,例如:

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

这篇关于F#取序列的子序列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆