Reputation: 1
I'm new to haskell and can't seem to figure this out. I've been using the scalpel web scraping tool and want to concatenate a bunch of URL extensions with a URL.
For example, lets say we have scraped some URL extensions into a list of strings
result =["/contact","/content"]
and we have let
websiteURL = "www.website.com"
how do I arrive at the list ?
["www.website.com/contact", "www.website.com/content"]
Upvotes: 0
Views: 475
Reputation: 83
You want to traverse your list of extensions and apply a function to each, so some kind of map
is required.
The function you want to apply is to append the websiteURL
string, so the answer is:
map (mappend websiteURL) result
If you didn't know the mappend
function, you could find it by searching hoogle for Monoid a => a -> a -> a
.
(I'll let other people generalize to more abstract types if they want...)
Upvotes: 0