Monday 6 June 2016

Haskell: Get all the names from list, that start with character ‘S’.

Prelude> let getNames names = [name | name <- names, head name == 'S' ]
Prelude> 
Prelude> getNames ["Sailu", "Ptr", "Nayan", "Sailaja", "devil"]
["Sailu","Sailaja"]

Previous                                                 Next                                                 Home

No comments:

Post a Comment