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

  Home users seem to be a target as they have nobody to

write a 200- to 300-word short-answer response to the followinghome users seem to be a target since they have nobody to

  A covert channel is a communication channel which violates

a covert channel is a communication channel that violates a security policy by using shared resources in ways for which

  Develop an application with the chosen dbms

A school intends to procure the integrated student management application holding all details of registered students including personal information, courses taken, and examination grades.

  How to make an xml file in visual studio

How to make an xml file in Visual Studio

  Describe the challenges that result from continual change

challenges as a result of continual change of technology1. describe the challenges that result from continual change of

  Cnsidering your chosen topic discuss how technologies or

considering your chosen topic discuss how technologies or information systems have contributed to the problem and how

  Define the expected benefits of the new system and for

-make a ppt presentation for this each section for about 3-4 slide with a notes carda. select networking hardware and

  How can the average person fight this

Recent news articles are talking about how Internet is being used as a method of posting slanderous, private or simply unverified information.

  Writing c code to determine the balance

Write down a program in C++ which determines the balance because of each month on a non-interest loan. Ask user for the loan amount and how much s/he will pay each month.

  Find out the gross pay for each of three employees

Your program must input this information for each employee, determine the employee's gross pay and output XHTML text that displays the employee's gross pay.

  Questiondons lumber company on hudson river is one of the

questiondons lumber company on hudson river is one of the oldest retail lumber yards in new york state. it features a

  Prepare the pseudocode for a program which accepts input

create the pseudocode for a program that accepts input values for the projected cost of a vacation and the number of

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