Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PLEASE HELPPP!!! LANGUAGE = SCHEME [20 marks] Define a procedure called make-list that implements the List ADT using an object oriented design in Scheme. The
PLEASE HELPPP!!! LANGUAGE = SCHEME
[20 marks] Define a procedure called make-list that implements the List ADT using an object oriented design in Scheme. The make-list procedure should return a list object. (Note: The List object you'll create is different from a native Scheme list, however, the backing implementation of the List object may use a standard list) The list object should have the following behaviours . (size) -returns an integer equal to the number of items in the list . (get i) returns the item stored at index i in the list . (set 1 x)-modifies index i in the list to hold item x . (add i x)-adds item x at index i in the list .(remove i) removes and returns the item at index i from the list . (print) displays the list in the standard scheme form (e.g. (a b c d)) For each of the functions. bad inputs (ie, invalid indices) should be checked. Return #f for any operation that should return a value but fails. Your code should be written in such a way that the following interactions would be valid (note: this does not constitute a complete test suite) (define L1 (make-list)) (define L2 (make-list)) (display "L1: ")((L1 'print)) (display "L2: ")((L2 'print)) ((L1 'add) 0 'a) ((L1 'add) 1 b) ((L1 'add) 2 C) ((L1 add) 3 d) (display "L1: ") ((L1 'print)) (U2 'add) ) ((L1 ,get ) 2)) (display "L2: ")((L2 'print)) ; printsL1 prints-L2: () ; prints L1: (a b c d) ; prints -L2: (c) [20 marks] Define a procedure called make-list that implements the List ADT using an object oriented design in Scheme. The make-list procedure should return a list object. (Note: The List object you'll create is different from a native Scheme list, however, the backing implementation of the List object may use a standard list) The list object should have the following behaviours . (size) -returns an integer equal to the number of items in the list . (get i) returns the item stored at index i in the list . (set 1 x)-modifies index i in the list to hold item x . (add i x)-adds item x at index i in the list .(remove i) removes and returns the item at index i from the list . (print) displays the list in the standard scheme form (e.g. (a b c d)) For each of the functions. bad inputs (ie, invalid indices) should be checked. Return #f for any operation that should return a value but fails. Your code should be written in such a way that the following interactions would be valid (note: this does not constitute a complete test suite) (define L1 (make-list)) (define L2 (make-list)) (display "L1: ")((L1 'print)) (display "L2: ")((L2 'print)) ((L1 'add) 0 'a) ((L1 'add) 1 b) ((L1 'add) 2 C) ((L1 add) 3 d) (display "L1: ") ((L1 'print)) (U2 'add) ) ((L1 ,get ) 2)) (display "L2: ")((L2 'print)) ; printsL1 prints-L2: () ; prints L1: (a b c d) ; prints -L2: (c)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started