Menu

Write Scheme Functions With The Following Description Usage Powerlist X Before X

3).

Write Scheme functions with the following description:

a).

Usage: (powerlist x)

Before: x is a finite list, x=(x1 x2 … x N)

After: The list (y1 y2 y3 …) 

For example: 

(powerless ‘()) should give (())

(powerlist ‘(1)) could give (() (1)) or the list ((1) ()).

(powerlist ‘(1 2)) could give (() (1) (2) ( 1 2 ))

b).

Usage: (cross a b )

Before: a and b are finite lists, a=(a1, a2, … aN)

       x=(b1, b2, … bM)

After: List, ((a1 b1) (a1 b2 … (a1 bM)..

For example :

(Cross ‘() ‘(1 2 3)) should give ()

(Cross ‘(1) ‘(4)) should give ((1 1 ))

(Cross ‘(1 2 ) ‘(3 4)) should give ((1 3) (1 4) (2 3) (2 4))

// map and append can be used 

Leave a Reply

Your email address will not be published. Required fields are marked *