[英]Insert element last into list
How do you insert an element (in this case, a char) into a list so it ends up as the last element? 如何将元素(在这种情况下为char)插入列表,使其最终成为最后一个元素?
For example, say that I want to add #"D"
as the last element in the list [#"A, #"B", #"C"]
so I then would have [#"A, #"B", #"C", #"D"]
. 例如,假设我要添加
#"D"
作为列表[#"A, #"B", #"C"]
的最后一个元素,那么我将有[#"A, #"B", #"C", #"D"]
。
(This should also work for inserting a string containing more than one element: adding [#"D", #"E"]
should give [#"A, #"B", #"C", #"D", #"E"]
.) (这对于插入包含多个元素的字符串也应该起作用:添加
[#"D", #"E"]
应该为[#"A, #"B", #"C", #"D", #"E"]
。
只需使用“ @”将其附加到末尾即可。
[#"A", #"B", #"C"] @ [#"D"]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.