将元素添加到列表末尾的最简单方法是什么? [英] What is the easiest way to add an element to the end of the list?
本文介绍了将元素添加到列表末尾的最简单方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
由于:: : 'a -> 'a list -> 'a list
用于将元素添加到列表的开始,有人可以告诉我是否存在将元素添加到结束的功能.列表中的?如果没有,我猜List.rev (element::(List.rev list))
是最简单的方法吗?
As:: : 'a -> 'a list -> 'a list
is used to add an element to the begin of a list, Could anyone tell me if there is a function to add an element to the end of a list? If not, I guess List.rev (element::(List.rev list))
is the most straightforward way to do it?
谢谢!
推荐答案
list@[element]
应该可以. @
加入列表.
list@[element]
should work. @
joins lists.
这篇关于将元素添加到列表末尾的最简单方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文