F#将元素添加到序列中 [英] F# Add an element to a sequence

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

问题描述

一个简单的问题,我找不到答案:如何在序列中添加元素?例如,我要添加一个seq和一个newElem XElement.

a simple question I cannot find an answer to: how to add an element to a sequence? Eg I have a seq and a newElem XElement I'd like to append to it.

谢谢

推荐答案

Seq.append:

Seq.append:

> let x = { 1 .. 5 };;

val x : seq<int>

> let y = Seq.append x [9];; // [9] is a single-element list literal

val y : seq<int>

> y |> Seq.toList;;
val it : int list = [1; 2; 3; 4; 5; 9]

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

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