Define procedure to return the sum of the odd elements, C/C++ Programming

Assignment Help:

(a) Define a procedure (deep-member x e) that takes a list x and an element e and returns #t if the element e is in the list or in any lists that the list x contains.

e.g., (deep-member (list 1 2 (list 3 4 (list 5 6))) 5) => #t

(b) Define a procedure (sum-odd x) that returns the sum of the odd elements in the list x. If an element is itself a list the embedded sum must also be included. In your solution for sum-odd, you must use the filter and accumulate procedures as defined in the notes.

e.g., (sum-odd (1 2 (3 4 5))) => 9

(c) Define a procedure (assoc-list k v) that takes 2 lists of keys, k, and values, v; a list of pairs is returned;

e.g., (assoc-list '(a b c) '(1 2 3)) => ((a.1) (b.2) (c.3)).

(d) Define a procedure (keys a) that takes an association list produced from (c) and returns a list of keys;

e.g., (keys a) => (a b c)

(e) Define a procedure (values a) that takes an association list produced from (c) and returns a list of values;

e.g., (values a) => (1 2 3)

(f) Define a procedure (append-copy x y) that takes 2 list arguments and returns the result of appending the two lists. The procedure must not use the built-in append procedure and must not suffer from the sharing problem as seen in the append procedure described in the notes. For example:

(define a (list 1 2 3))
(define b (list 4 5 6))
(define c (append-copy a b))
c ; Should display (1 2 3 4 5 6)
(set-cdr! b (list 9 10))
c ; Should display (1 2 3 4 5 6)


Related Discussions:- Define procedure to return the sum of the odd elements

Is there present a way to force new to allocate memory, Yes. "Memory pools"...

Yes. "Memory pools" are useful in many situations. The bad news is that I'll need to drag you through the mire of how it acts before we talk about all the uses. Firstly, recall

Explain structures, Structures A structure is a derived data type. It i...

Structures A structure is a derived data type. It is a combination of logically related data items. Unlike arrays, which are a collection of such as data types, structures can

Decode, Smugglers are becoming very smart day by day. Now they have develop...

Smugglers are becoming very smart day by day. Now they have developed a new technique of sending their messages from one smuggler to another. In their new technology, they are send

Assignment, Design a black box suit for function whether a character or st...

Design a black box suit for function whether a character or string up to 25 characters

Write a program read words from file, Write a program IdentyfyWordsMain.jav...

Write a program IdentyfyWordsMain.java reading a fi le (like HistoryOfProgramming) and divide the text into a sequence of words (word=sequence of letters). Save the result in a new

Define a class?, Define a class? A: It is an expanded concept of a data ...

Define a class? A: It is an expanded concept of a data structure: rather than holding only data, it can hold data and functions both.

Record of student and calculating marks using ctotal, reocord of a student ...

reocord of a student and a function ctotal to calculate the marks of any three subject by using ctotal() function

Write Your Message!

Captcha
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