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

Graphical user interface designed for the output peripherals, Introduction ...

Introduction to I/O interfacing, discuss microcontrollers applications in industry. Detailed product design specifications that have sections on both hardware and software inclu

Accessibility, What are the legal requirements with which websites must com...

What are the legal requirements with which websites must comply in order to meet the needs of persons with disabilities? Why is maximizing accessibility important to everyone?

C program for function of compound interest, C Program for FUNCTION  OF CO...

C Program for FUNCTION  OF COMPOUND INTEREST float ci(float,float,float); void main() {           float p=0,r=0,n=0,k=0;           clrscr();           printf("EN

Decodethecode, 6999066263304447777077766622337778 -----> message sent by th...

6999066263304447777077766622337778 -----> message sent by the first smuggler. my name is robert---------> message decoded by the second smuggler. Where ‘0’ denotes the "space". Ex

Explain about the integer constants in c language, Explain about the Intege...

Explain about the Integer constants in c language? An integer constant is the integer valued number and it refers to a sequence of digits. A decimal integer constant includes o

Described container class?explain types of container class, A container cla...

A container class is a class which is used to hold objects in external storage and memory. A container class work as a generic holder. A container class contains a predefined behav

Minimum shelves, write a c++ program, that finds the minimum total number o...

write a c++ program, that finds the minimum total number of shelves, including the initial one, required for this loading process.

Program to create a class and store student information, Develop a Student ...

Develop a Student class that has the following header file: #ifndef STUDENT_H #define STUDENT_H #include #include #include using namespace std; class Stu

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