Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Rewrite the following s-expressions using the list notation of Scheme. If you do

ID: 3813208 • Letter: R

Question

Rewrite the following s-expressions using the list notation of Scheme. If you don't think it can be rewritten, indicate so and explain why not. If it can be partially rewritten (i.e. you can eliminate some but not all of the "dots"), do as much as possible a. (3. NIL) b. ((2 NIL). (9. NIL)) c. (3. (4. (5. (6. NIL) (7. NIL))))) d. (3. (4.5)) Rewrite the following lists to use dot notation. If you don't think it can be done for a particular list, indicate so and explain why not. If it can be partially rewritten then do as much as possible. a. (4) b. (45) c. (4 (5)) d. (4) 5) e. (4) (5) 6)

Explanation / Answer

1.

a.)

-> given s - expression

( 3 . NIL )

-> here NIL end of list object. It can be eliminated in lists with dots.

so ( 3 . NIL ) in list form = ( 3 )

b.)

-> given s - expression

( ( 2 . NIL ) .  ( 9 . NIL ) )

-> here NIL end of list object. It can be eliminated in lists with dots.

so ( ( 2 . NIL ) .  ( 9 . NIL ) ) in list form =( ( 2 ) . (9) ) = ( 2 9 )

c.)

-> given s - expression

( 3 . ( 4 . ( 5 . ( ( 6 . NIL ) .  ( 7 . NIL ) ) ) ) )

-> here NIL end of list object. It can be eliminated in lists with dots.

so ( 3 . ( 4 . ( 5 . ( ( 6 . NIL ) .  ( 7 . NIL ) ) ) ) )   in list form = ( 3 . ( 4 . ( 5 . ( ( 6 ) .  ( 7 ) ) ) ) )

  = ( 3 . ( 4 . ( 5 . ( 6 . 7 ) ) ) )

here it is list . stop if not eliminate dots. otherwise

eliminate dots as = ( ( 3 ) ( ( 4 ) ( ( 5 ) ( 6 7 ) ) ) )

d.)

-> given s - expression

( 3 . ( 4 . 5 ) )

-> since there is no end object NIL , Itself it is list in pair .

required list is ( 3 . ( 4 . 5 ) )

2 .

a. )

given list is ( 4 )

-> here no need to put . in the list because only one value in the list as expression .

-> but only put dot between last object and NIL . i.e ( 4 . NIL )

b. )

given list is ( 4 5 )

-> here dot has to be kept between two objects.

so required dot notation = ( 4 . 5 ) or ( ( 4 . NIL ) .  ( 5 . NIL ) )

c. )

given list is ( 4 ( 5 ) )

-> here dot has to be kept between two objects.

so required dot notation = ( 4 . ( 5 ) ) or ( 4 .  ( 5 . NIL ) )

d. )

given list is ( ( 4 ) 5 )

-> here dot has to be kept between two objects.

so required dot notation = ( ( 4 ) . 5 ) or ( ( 4 . NIL ) . 5 )

e. )

given list is ( ( 4 ) ( 5 ) ( 6 ) )

-> here dot has to be kept between two objects.

so required dot notation = ( ( 4 ) . ( 5 ) . ( 6 ) ) or ( ( 4 . NIL ) .  ( 5 . NIL ) . (6 . NIL ) )

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote