Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Please write in scheme language.
Write a Scheme procedure that sums all the elements in a given list of numbers.
It takes input from the user as a list. Then it returns sums of elements in this list of numbers.
Let's say The user enters 1 2 3 4 as a list. It must be returned 10 ( 1+2+3+4=10)
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 steps
Knowledge Booster
Similar questions
- Please answer quickly In pythonarrow_forwardSuppose you have a list of key/value pairs (i.e., a nested list where each element of the list is a (key value)pair. For example, the list might look like this: '((France Paris) (France Nice) (Spain Madrid) (Poland Krakow) (Poland Warsaw)) (Notice that the keys need not be unique for this problem.) Write a function named first-occurrence in Scheme that takes a key and a list then returns the value of the first item on the list with a matching key. Return '() if none of items on the list has a matching key. You must use either fold or reduce to do the vast majority of the work. You may use the built-in foldmethod by adding the line (require 'list-lib), or you can use your own implementation. The built-in fold function has parameters in this order: action partial-result lst. You may assume that the list contains an element with the key to be updated. For example, (first-occurrence 'Germany '((France Paris) (Germany Bonn) (Germany Berlin))) should return 'Bonn (first-occurrence 'Poland…arrow_forwardrite a function numPairs that accepts two arguments, a target number and a list of numbers. The function then returns the count of pairs of numbers from the list that sum to the target number. In the first example the answer is 2 because the pairs (0,3) and (1,2) both sum to 3. The pair can be two of the same number, e.g. (2,2) but only if the two 2’s are separate twos in the list.In the last example below, there are three 2’s, so there are three different pairs (2,2) so there are 5 pairs total that sum to 4. Sample usage: >> numPairs( 3, [0,1,2,3] )2arrow_forward
- in c++ please paste working code. the program should Input- Julia Lucas Mia -1 With an expected output of- Julia Lucas Mia Julia Mia Lucas Lucas Julia Mia Lucas Mia Julia Mia Julia Lucas Mia Lucas Juliaarrow_forwardCreate a program in R5RS (a dialect of scheme) to take a list of atleast 2 integers and return the maximum length of two sublists that have the same sum. for example 1,2,3,4 would have sublists of 1,4 and 2,3 and the output would be 2. However if no possible sublists can be made to fit the above criteria return 0. Not all numbers from a list need to be used in the sub lists, for example the list 1,-1,2,-3,4,-2 would have sublists of 1,-1 and 2,-2 and would return 2. So basically find every possible sublist and then return the length of the biggest sublists that have matching sums and lengths, so even the list 4,4 would return 1. This should be done in one recursive function and one cond statement and all parameters excludeing the list should be initialized with values of 0 which should roughly look like: (define sublists (lambda (List followed by any other parameters) (cond code ))). we can only use…arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY