Monday, 6 June 2016

Haskell: Get all the first elements of list of tuples

Prelude> let firstElements tup = [(fst p) | p <- tup]
Prelude> 
Prelude> firstElements [(1, 1), (2, 4), (3, 9), (4, 16), (5, 25)]
[1,2,3,4,5]

Previous                                                 Next                                                 Home

No comments:

Post a Comment