Saturday, 30 April 2016

Haskell: Concatenate two lists


By using ++ operator, you can concatenate two lists.

*Main> let list1 = [2, 3, 5, 7]
*Main> let list2 = [2, 4, 6, 8, 10]
*Main> 
*Main> let list3 = list1 ++ list2
*Main> let list4 = list2 ++ list1
*Main> 
*Main> list1
[2,3,5,7]
*Main> 
*Main> list2
[2,4,6,8,10]
*Main> 
*Main> list3
[2,3,5,7,2,4,6,8,10]
*Main> 
*Main> list4
[2,4,6,8,10,2,3,5,7]
*Main> 


Previous                                                 Next                                                 Home

No comments:

Post a Comment