Reputation: 2849
Is it possible to create a list by combing elements of a list 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"]
?
Upvotes: 7
Views: 22498
Reputation: 118865
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]
Upvotes: 21