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
The advantage of an electronic ____ is that the content can be easily edited and updated to reflect changing financial condition
Lana71 [14]
Computer.................................
6 0
3 years ago
Tiling is when a browser loads a background image and then repeats the image in both the vertical and horizontal directions unti
jeyben [28]
The correct answer is true
7 0
3 years ago
Read 2 more answers
A stigma is
mario62 [17]
The answer to your question is A. A mark of social disgrace that sets tyre deviant apart from the rest of society. Hope I helped.
8 0
3 years ago
Read 2 more answers
What are somd negetive aspects and some positive aspects of having robots as a part of workplace?
aksik [14]

Answer and Explanation:

Some of the negative aspects of robots at work place:

  • Lesser flexibility
  • Higher maintenance and installation cost
  • Future insecurity and risk if the system malfunctions
  • A decline in the opportunities for humans
  • Unemployment as a result of automation and robot regulated work place.

Some of the positive aspects of robots at work place:

  • Higher accuracy
  • Higher speeds
  • More work in less time
  • Productivity and hence efficiency will increase
  • Cost of some operations is reduced.
  • Ease of employing in dangerous and hazardous fields by using specific robots for each task
5 0
2 years ago
Why is web arnea of so much commetition today
Sonja [21]

Answer:

try checking your internet or reset your computer if that still dosnt work try putting all your stuff on an USB stick and then after you did that factory data reset your computer and that should work but before you reset your computer take it into a computer specialist

Explanation:

8 0
3 years ago
Other questions:
  • When you move or size a control in the Form Designer, Visual Studio automatically adjusts the ________________ that specify the
    9·1 answer
  • Constructors have the same name as the ____.1. data members2. member methods3. class4. package
    5·1 answer
  • Which component is a part of the central processing unit (CPU) of a computer
    11·2 answers
  • Violations of security policies are considered to be a(n) __________ issue upon which proper disciplinary actions must be taken.
    7·1 answer
  • Is downloading like installing?
    13·1 answer
  • Which member of the Jackson family was the spokesperson for the Psychic Friends Network.​
    7·1 answer
  • Hello pls answer<br><br><br>what is the use of loop in java​
    5·1 answer
  • Select the correct answer.
    10·1 answer
  • How did technology change the world
    15·2 answers
  • Array bounds checking should be directly coded into a system rather than assumed.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!