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]
精彩评论