Define a procedure that takes a list as a single argument, Programming Languages

(a) Define a procedure (subsets x) that takes a list as a single argument and returns all 2^n subsets of that list, i.e. the power set of the list;

e.g. (subsets '(a b c)) ==> (() (c) (b) (b c) (a) (a c) (a b) (a b c))             

The order of the subsets returned is not important.

(b) Define an iterative function (filter pred lst) that applies a predicate pred to each element of a list lst and returns a list of elements that satisfy the predicate; e.g. (filter even? '(1 2 3 4 5 6)) ==> (2 4 6).

(c) Define a procedure (interleave x y) that takes 2 list arguments and returns the 2 lists interleaved; e.g. (interleave '(a b c) '(d e f)) => (a d b e c f).

You must deal with the case when the two lists are not of equal

Posted Date: 3/30/2013 6:24:43 AM | Location : United States







Related Discussions:- Define a procedure that takes a list as a single argument, Assignment Help, Ask Question on Define a procedure that takes a list as a single argument, Get Answer, Expert's Help, Define a procedure that takes a list as a single argument Discussions

Write discussion on Define a procedure that takes a list as a single argument
Your posts are moderated
Related Questions
Please remember to read and follow all of the assignment guidelines. This assignment will expand upon the simulation algorithm given in class to produce a program which may be u

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

There actually isn't all that much to this section. All we are going to do now is work a quick illustration using Laplace transforms for a 3 rd order differential equation therefo

Write a Perl script that prints the contents of a file Write a Perl script that prints the contents of a file, prefixing each line with a line number. The script should acc

We want a program, a logic, we can list the intermediate films sandwiched between the 2 tapes (from - to) that indicates the user. example: From to

Simpson's Rule is a more accurate method of numerical integration than the method described in class. Using Simpson's Rule, the integral of a function f between a and b is approxim

Define the Control statements in Computer Programming? The statements are part of the program that performs some action. The compiler will check a program sequentially from the

Question: (a) Explain the concepts of Inheritance and Polymorphism in Lingo programming. (b) Write short descriptions on parent scripts and child objects in Lingo object

Solve the following initial value problem y (3) - 5y'' - 22y' + 56 y= 0;       y(0) = 1;           y'(0) = -2;         y''(0) = -4 Solution : r 3 - 5r 2 - 22r + 56 = (

Plan, design and dry run a program for the Little Man Computer (LMC) that produces the same result using a fixed number of 10 iterations.