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

(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)

Posted Date: 3/25/2013 1:08:18 AM | Location : United States







Related Discussions:- Define procedure to return the sum of the odd elements, Assignment Help, Ask Question on Define procedure to return the sum of the odd elements, Get Answer, Expert's Help, Define procedure to return the sum of the odd elements Discussions

Write discussion on Define procedure to return the sum of the odd elements
Your posts are moderated
Related Questions
v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} Normal 0

The continue statement The continue statement causes the next iteration of the enclosing loop to start. When this is encountered in the loop , the rest of the statements in the

Aim: To implement a program to swap two numbers using reference arguments. Code: void swap(int *a, int *b) {             int temp;             temp=*a;

¦It should ask customers to enter details such as their names and addresses. ¦It should print a welcome message that includes the customer’s name. ¦It should provide a list of avai

Project Description: I´ve a need linux programming job. if you are interested, Skills required are C Programming, PCB Layout, Embedded Software, Python, Software Architecture

How to write a function template A function template should be written at the beginning of the program in the global area, or you may place it into a header file. All function

Should one design a classes from the outside (interfaces first) or inside (data first)? A: From the outside. A superior interface provides a simplified view which is express

how we use the cin command and why we use this command????

#include stdio.h   struct  complex   {   float real;   float imag;   };   struct complex complexadd(struct complex,struct  complex);   void main()     {          Date: 26

There is a pebble merchant. He sells the pebbles, that are used for shining the floor. His main duty is to take the length of the room’s sides. But he sometimes mistakes doing that