Scheme Functions 2.0

Completed Posted Apr 5, 2004 Paid on delivery
Completed Paid on delivery

1. Define a procedure **subst-all** with call structure **(subst-all new old ls)** that replaces _each_ occurrence of the item **old** in a list **ls** with the item **new**. The following are sample results:

(subst-all 'one 'two '()) => '()

(subst-all 0 '(1) '(((1) (0)))) => '((0 (0)))

(subst-all 'z 'a '(a (b (a c )) (a (d a ))))=> '(z (b (z c)) (z (d z)))

2. Define a procedure **insert-left-all** with call structure **(insert-left-all new old ls)** that inserts the item **new** to the left of each occurrence of the item **old** in the list **ls**. The following are sample results:

(insert-left-all ' z 'a '()) => '()

(insert-left-all 'z 'a '(((a))))=> '(((z a)))

(insert-left-all 'z 'a '(a ((b a) ( ( a (c) ))))) =>

(z a (( b z a) (( z a (c)))))

(3) Define a procedure **sum-all** that finds the sum of

numbers in a list that may contain nested sublists of

numbers. The following are sample results.

(sum-all '()) => 0

(sum-all '(1 (3 (5 (7 (9)))))) => 25

(sum-all '((1 3) (5 7) (9 11))) => 36

## Deliverables

1.

2. Define a procedure **count-background-all** that takes as its arguments **item** and a list **ls** and returns the number of items in **ls** that are not the same as **item**. Use the most general sameness predicate. The following are sample results:

(count-background-all 'b '()) => 0

(count-background-all 'a '((((b (((a)) c)))))) => 2

(count-background-all 'a '((a) b (c a) d)) => 3

3. Define a procedure **notate-depth** that takes a list and produces a list similar to the original, except that each _symbol_ is replaced by a list containing the symbol and a number equal to the depth at which the symbol appears in the original list. A symbol appearing at the top level of the list is at depth 0; a symbol appearing in an immediate sublist is at depth 1, etc. For example:

(notate-depth '( a (b () c) ) ( (d)) e)) =>

((a 0) (( b 1) () (c 1)) ((( d 2 ))) (e 0))

## Platform

Restrictions :

1. Each of the functions must be specified using the full *lambda expression* to emphasize that they are first class entities in the language. .

2. Use the mutator *set!* in a judicious manner.

_*I am using SISC (second interpreter of scheme code) which can be downloaded free from

[url removed, login to view]*

_

THE DUE DATE FOR THIS IS FRIDAY APRIL 9TH 04.

Engineering MySQL PHP Software Architecture Software Testing

Project ID: #3160077

About the project

3 proposals Remote project Active Apr 8, 2004

Awarded to:

milan077

See private message.

$12 USD in 5 days
(17 Reviews)
4.1

3 freelancers are bidding on average $28 for this job

coppock

See private message.

$29.75 USD in 5 days
(15 Reviews)
3.8
wcbarksdale

See private message.

$42.5 USD in 5 days
(0 Reviews)
0.0