1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Xelga [282]
3 years ago
9

p3_unzip :: [(a,b)] -> ([a], [b]) Write a function that takes a list of two-tuples and returns a tuple of two lists -- the fi

rst containing the first element of each tuple, and the second the second element (i.e., the reverse of "zip"). Examples: > p3_unzip [('a',1),('b',5),('c',8)] ("abc",[1,5,8])
Computers and Technology
1 answer:
klio [65]3 years ago
4 0

Answer:

<em>C++.</em>

Explanation:

#include <iostream>

#include<tuple>

using namespace std;

////////////////////////////////////////////////////////////

tuple<char*, int*> p3_unzip(tuple<char, int>* list, int count) {

   char* list1 = new char[count];

   int* list2 = new int[count];

   

   for (int i=0; i<count; i++) {

       tuple<char, int> temp = list[i];

       list1[i] = get<0>(temp);

       list2[i] = get<1>(temp);

   }

   

   tuple<char*, int*> new_tuple;

   get<0>(new_tuple) = list1;

   get<1>(new_tuple) = list2;

   

   return new_tuple;

}

int main() {

   tuple<char, int>* list;

   int count = 0;

   ////////////////////////////////////////

   cout<<"How many tuples? ";

   cin>>count;

   list = new tuple<char, int>[count];

   cout<<endl;

   

   char a;

   int b;

   tuple<char, int> temp;

   for (int i=0; i<count; i++) {

       cout<<"tuple "<<i+1<<" char: ";

       cin>>a;

       get<0>(temp) = a;

       

       cout<<"tuple "<<i+1<<" int: ";

       cin>>b;

       get<1>(temp) = b;

       

       list[i] = temp;

       cout<<endl;

   }

   ////////////////////////////////////////

   tuple<char*, int*> new_tuple = p3_unzip(list, count);

   char* list1 =  get<0>(new_tuple);

   int* list2 = get<1>(new_tuple);

   

   cout<<"Returned tuple:([";

   for (int i=0; i<count-1; i++) {

       cout<<list1[i]<<", ";

   }

   

   cout<<list1[count-1]<<"],[";

   

   for (int i=0; i<count-1; i++) {

       cout<<list2[i]<<", ";

   }

   

   cout<<list2[count-1]<<"])";

   ////////////////////////////////////////

   delete[] list, list1, list2;

   return 0;

}

You might be interested in
What effect did personal computers and internet have on how people acces information
Ganezh [65]
Personal computers made accessing information a lot faster and easier but a lot of times the things we see when we search information is tailored to our personal beliefs and opinions. For example, if you're a person that commonly searches for information or products about dogs, you're way less likely to get an add promoting cat food. While this may seem like a very positive thing, it also may have a downside. This rule also applies to things like political views, if you're a trump supporter you'll most likely end up seeing things that are pro-Trump and a lot fewer things that are pro-Hilary. 

This can skew people's outlooks on certain subjects, if you're only ever seeing web pages and articles saying that Trump is great, you won't ever see the opposing side which is essential in making a well-informed decision about a candidate for the presidency or any other subject for that matter.

In summary, You have to see both the good and bad side of something to truly make a choice and the way the internet works can sometimes make that difficult.


I hope this helps and makes sense! :)
6 0
3 years ago
Read 2 more answers
What is installing?
GalinKa [24]

The process of putting new software on a computer

3 0
2 years ago
Read 2 more answers
The device that store data and program for current purpose​
Musya8 [376]

Answer:

A computer, what you are using. smh.

6 0
3 years ago
Read 2 more answers
____ technology is the same as that used in digital watches, or the time display on a microwave oven
erma4kov [3.2K]
Digital technology is the same as the used in digital watches, or the time display on a microwave oven. Digital is about using the exact numbers to tell the time. By being digital transmission of data became easy. Sound, images and document are relayed faster and stored conveniently through this system.
4 0
3 years ago
What information on social networking sites could be used to discriminate against a potential employee
NISA [10]

the answer on plato is b

political affiliations

3 0
3 years ago
Other questions:
  • Who is typically considered to be the father of computing
    6·1 answer
  • How do you copy and paste a screenshot on an hd computer
    12·2 answers
  • The merge sort algorithm____________.A. Can be used only on vectors of even length.B. Works by reducing vectors down to the base
    9·1 answer
  • Write a program that asks the user to enter two integer numbers X and Y. The program halves each number between X and Y then pri
    15·1 answer
  • Can someone find out what this binary number thing is. Just find out the message, I'm having a difficult time
    13·1 answer
  • TRUE OR FALSE: THE BUILDER'S CLUB IS A PAID SUBSCRIPTION.
    9·2 answers
  • What might a designer need to consider when choosing an appropriate energy source for products and power systems
    15·1 answer
  • You have a passage of text that needs to be typed out, but some of the letter keys on your keyboard are broken! You're given an
    14·1 answer
  • Type the correct answer in the box
    13·1 answer
  • What was the first computer
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!