Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7490969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:47:54+00:00 2026-05-29T15:47:54+00:00

This question is about functional programming, not about how to build URL query strings.

  • 0

This question is about functional programming, not about how to build URL query strings. The language I’m working in is Objective-C but that’s also not especially relevant.

I have a starting data structure that’s an array of strings. Each odd element is the parameter name, each even one is the value eg, [firstname, bob, lastname, smith, gender, male].

Is there an idiomatic FP approach to converting this list into a URL query string (eg. “firstname=bob&lastname=smith&gender=male”)?

I’m thinking something along the lines of ‘partition using a mod 2 predicate’ to give me 2 lists of keys and values respectively, then zipWith a function that url escapes the keys and values and joins them with ‘=’. That will give me a list of ‘a=b’ strings. Then I should be able to do a fold-left to insert the ‘&’ symbols.

I think I may have just answered my own question! Sweet! Posting it anyway in case someone more familiar with FP idioms wants to comment.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T15:47:55+00:00Added an answer on May 29, 2026 at 3:47 pm

    Here’s a more-or-less direct translation of your English into C#:

    var list = new[]{"firstname", "bob", "lastname", "smith", "gender", "male"};
    
    string.Join("&", 
                list.Where((k, i) => i % 2 == 0)
                    .Zip(list.Where((v, i) => i % 2 == 1),
                        (k, v) => k + "=" + v));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is not quite a programming question, but it's about a programming environment, so
Followed this question about delayed_job and monit Its working on my development machine. But
This time I have a question about C++. I'm using Dev-C++ for programming, but
I have a question about this question . I posted a reply there but
This is somewhat of a broad question, but it is one that I continue
There was this question posted in class today about API design in socket programming.
This question about Timers for windows services got me thinking: Say I have (and
This question is a follow up to my previous question about getting the HTML
I was reading this question about how to parse URLs out of web pages
I just came across this question about initializing local variables. Many of the answers

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.