开发者

Combining elements in a list - OCaml

Is it possible to create a list by combing elements of a lis开发者_StackOverflowt rather than creating a list of lists?

Example:

List.combine ["A";"B"] ["C";"D"];;

I get:

[("A", "C"); ("B", "D")]

Is it possible to generate ["A";"B";"C";"D"] ?


I think the @ operator or List.append is what you want.

Example with the @ operator:

# let x = 4::5::[];;
val x : int list = [4; 5]
# let y = 5::6::[];;
val y : int list = [5; 6]
# let z = x@y;;     
val z : int list = [4; 5; 5; 6]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜