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

  Determine technology which has changed cafe,coffee shop

Determine technology which has changed cafe,coffee shop? Think things such as marketing, food preparation, inventory ordering or re-ordering, customer tracking, and more.

  This paper must start with the identification of trigger

students will submit a 750-1000-word paper double spaced this week identifying and describing the key components of a

  Design a flowchart and pseudo-code

You have a file containing the grades of students from Beginning Programming, along with students' information. Your part of the program has to loop through the records, and create sure that any student who has received a 'D', 'W', 'I', or 'F' in ..

  Show the amount of time

Convert the pseudocode given below into an executable shell script for Knoppix, following the similar order.

  Flow chart in modular approach

Design an algorithm in order to prepare a daily hotel charge report. Input comprises of the series of records that consists of the room number, the customer name, cost of room.

  Compare x.509 pki and pgp pki in different aspects

Compare X.509 PKI and PGP PKI in different aspects, e.g. Certs format, user identification, key management, scalability, usage, applications, business models, etc.

  What is the expected time to find a key by exhaustive

Given a computer that can test 2^40 keys each second. What is the expected time to find a key by exhaustive search given a key space, say 2^88. How do you go about figuring this out? Is there a formula or standard equation that is used?

  In-house development of software

Discuss the innovative and creative ways in order to use patient ID bracelet consisting of a bar-code representation of patient's ID.

  Which is implemented using linked lists

An array can be used to hold a complete or full binary tree. Explain how he data structure would be set up and how a node's left and right children can be reached. What changes would be needed if there was a requirement to handle non-full, non-comp..

  Create a gui pad that has numbers and letters

Create a GUI pad that has numbers and letters(That can be capitalized), and a text area to display One button that clears the text.

  Compute and conclude the speedup for options

Compute and conclude the speedup for options and decide the option Processor Y should take.

  Explore paper on vmware security

Explore paper on VMware Security

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