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

C program for bank account, Aim: To implement a program for bank account u...

Aim: To implement a program for bank account using static data type. Code: class bank {             static int acc_no;             int acc;             float b

C program to check prime numbers , C Program to check PRIME NUMBERS   ...

C Program to check PRIME NUMBERS   main() {           int i,k,r,flag;           clrscr();           printf("ENTER THE NO. TO CHECK IT IS PRIME OR NOT: ");

Program to convert compass heading in degrees , Convert compass heading in ...

Convert compass heading in degrees (0-360 degrees)to compass bearing. A compass bearing consist of three items namely: a.The direction you face (North or South) b.An angle betwe

Recursive functions, a program to determine whether a number is an odd or e...

a program to determine whether a number is an odd or even using recursive function

Define the classification of operators in c language, Define the Classifica...

Define the Classification of Operators in C Language? Depending on the function performed the operator can be classified as 1. Arithmetic Operator 2. Logical Operator 3. Inc

Lennie, Lennie McPherson, proprietor of Lennie''''s Bail Bonds, needs to ca...

Lennie McPherson, proprietor of Lennie''''s Bail Bonds, needs to calculate the amount due for setting the bail. Lennie requires something of value as collateral, and his fee is 10%

Resection method, recsection method source code for searching position

recsection method source code for searching position

List, Is there any difference between List x; and List x ()? Can you please...

Is there any difference between List x; and List x ()? Can you please provide me assignment help.

Project, Project Overview A certain financial institution (bank) wishes to ...

Project Overview A certain financial institution (bank) wishes to promote its new business products/services by conducting road shows in rural areas. Their aim is to encourage peop

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