开发者

Combining elements in a list - OCaml

开发者 https://www.devze.com 2023-01-27 19:19 出处:网络
Is it possible to create a list by combing elements of a lis开发者_StackOverflowt rather than creating a list of lists?

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

精彩评论

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