Sums each component of the pairs

Assignment Help Computer Engineering
Reference no: EM13708803

Question: Write a version of sumPairs of Ex. 3.1.8 that sums each component of the pairs discretely, returning a pair consisting of the sum of the first components and the sum of the second components. So essentially [(3,1)(10,3)] would return (13,4).

Ex. 3.1.8

fun sumPairs(nil) = 0

| sumPairs((x,y)::zs) = x + y + sumPairs(zs);

I'm trying to solve this by using the let, in, and end. Here is what I have so far:

fun sumPairs(nil) = 0

| sumPairs((x,y)::zs) =

let

val P = x + sumPairs(zs);

val Q = y + sumPairs(zs)

in

sumPairs(P,Q)

end;

Unluckily, it does not work.

I wrote this but it's not working. Can you please help me edit the code so it works or else prepare a new code.

Reference no: EM13708803

Questions Cloud

Sum of the odd positions of the list : Write a function that takes a list of integers as argument and returns a pair consisting of the sum of the even positions and the sum of the odd positions of the list.
Explain the path a process : Explain the path a process might take through the five states specified in the five-state model discussed in the text?
Two dimensional int array to hold the prices of the seats : The Theater class shows a theater with an auditorium containing a fixed number of seats arranged in rows with each seat selling for a exacting price. The instance variables for the theater are:
Translates a number into the closest letter grade : Write a program that translates a number into the closest letter grade. For case, the number 2.8 which might have been the average of several grades would be converted to B-
Sums each component of the pairs : Write a version of sumPairs of Ex. 3.1.8 that sums each component of the pairs discretely, returning a pair consisting of the sum of the first components and the sum of the second components. So essentially [(3,1)(10,3)] would return (13,4).
The boiling points of alcohols are lower than the ketones : Question- The boiling points of alcohols are lower than the corresponding ketones with similar molecular weight.
Calculate the solubility of cubr : Question- Copper (i) ions in aqueous solution react with NH3 (aq) according to Cu^+ (aq) + 2NH3 (aq) ----------------> Cu (NH3)2^+ (aq) Kf = 6.3 X 10 ^10 Calculate the solubility (in g * L^-1) of CuBr (s) (Ksp = 6.3 X 10 ^-9) in 0.88 M NH3 (a..
Design an adt for a two-color : Design an ADT for a two-color, double-stack ADT that consists of two stacks one "red" and one "blue" and has as its operations color-coded versions of the regular stack ADT operations.
What is the concentration of m +2 ions at equilibrium : Question- The formation constant of [M (CN)6] ^-4 is 2.50 X 10 ^17 where M is a generic metal. A 0.160 mole quantity of M (NO3)2 is added to a liter of 1.190 M NaCn solution. What is the concentration of M +2 ions at equilibrium

Reviews

Write a Review

Computer Engineering Questions & Answers

  Q1answer following questions in short and to the point

q.1.answer following questions in short and to the point only.a what are the strategies kernel chooses for handling

  Find out which servers might need more system resources

define what components she'll need to add or upgrade, at minimum, to make Nichol's servers capable of running Windows Server 2008. Also, explain why you don't recommend leaving all the servers at the minimum hardware requirements. Write down four ..

  Questionwrite down a java program that uses a

questionwrite down a java program that uses a two-dimensional array to store the highest and lowest temperatures for

  Design a new villian value called badguy

Also suppose the existence of a function copyVillian (as declared below) that takes two Villian params, one called orig and the other called copycat, and makes copycat a deep copy of orig.

  Create class named counter that has one string field

create a Main class that has the normal main method that you need to start the program. The main method should ask the user for the name of a local input file.

  Define the difference between an interpreter and a compiler

How does uncertainty affect computer programs and databases when it occurs.Why don't decision trees work well for planning, scheduling, or synthesis problems.

  Eurofins scientific is a bioanalytical service provider

Require a Project plan for the project (it doesn't need to be in ms project, word is fine). Including timelines, tasks and constraints. The project is a fictional business and idea that I needed to come up with and make a project plan, please allo..

  Why vista a better choice for home or office computing

Investigate net for information about some of the new features offered by Vista over previous operating systems or operating systems on other computing environments.

  Describe about the internet impact in terms of the social

the internet has made a large impact on the daily lives of people all over the world.consider all of the changes that

  How the core issue depend on who wrote the code

how the core issue depend on who wrote the code

  What duty cycle signal is required

What duty cycle signal is required to run the motor at approximately 20 rpm?

  Create a short main() demonstration program

make two classes. The first holds sales transactions. Its private data members include date, amount of sale, and salesperson's ID number.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd