Skip to content

Instantly share code, notes, and snippets.

@Jamil
Last active August 29, 2015 14:07
Show Gist options
  • Select an option

  • Save Jamil/85049803f6bae359c966 to your computer and use it in GitHub Desktop.

Select an option

Save Jamil/85049803f6bae359c966 to your computer and use it in GitHub Desktop.
Create URL with query parameters from base and key-value pairs
createURL :: String -> [(String,String)] -> String
createURL base parameters = base ++ (makePairs parameters)
where
makePairs (x:xs) = foldl (++) (makeHead x) (map (\p -> "&" ++ (makePair p)) xs)
makeHead x = "?" ++ (makePair x)
makePair (key,value) = key ++ "=" ++ value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment