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 7092517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:19:24+00:00 2026-05-28T08:19:24+00:00

Using my zip function(see below), write a function addpairs that takes two lists [x0;

  • 0

Using my zip function(see below), write a function addpairs that takes two lists [x0; x1; … ; xn] and [y0; y1; … ; ym] and returns the list [x0 + y0; x1 + y1; … ; xp + yp], where p = min(n; m). Where this is the output from console.

*Recursion> :t addpairs
addpairs :: (Num a) => [a] -> [a] -> [a]
*Recursion> addpairs [1,2,3,4] [40,50,60,90]
[41,52,63,94]

my zip function:

zip [] _ = []
zip _ [] = []
zip (a:aa) (b:bb) = (a,b) : Recursion.zip aa bb

Any help would be great.

I actually solved this problem
This was the solution I came up with:

addpairs xs ys = map f (Recursion.zip xs ys)
  where f (x,y) = x + y

Thanks for all that helped.

  • 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-28T08:19:25+00:00Added an answer on May 28, 2026 at 8:19 am

    If xs and ys are the two lists your function is given, then zip xs ys will be a list of tuples of numbers to add:

    GHCi> zip [1,2,3,4] [40,50,60,90]
    [(1,40),(2,50),(3,60),(4,90)]
    

    zip xs ys will have the type [(a,a)] for some numeric type a. Next, take a look at the type of map:

    map :: (a -> b) -> [a] -> [b]
    

    Your function should look like this:

    addpairs xs ys = map f (zip xs ys)
      where f ...
    

    where f should be a function taking an (a, a) to be added and returning the resulting a. That should help you fill in the rest.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using this function to extract files from .zip archive and store it on
While browsing System.Zip (Delphi XE2) to see how it works, I found this function:
I would like to write a JavaScript function that validates a zip code, by
I want to see implementation of java.util.zip.CRC32. But within this class its using native
I have found that creating a zip file using the Zip task provided by
I am validating a zip code using Javascript that is generated server-side, and injected
Using this code to zip a folder and it works perfect on small files
I am trying to build an elegant transpose function using functions mapn and zip
I'm trying to write out a zip file using the wxZipOutputStream. The code is
The thing is like this. I have a zip file with images that uncompressing

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.