Question: Question 5 ; Input contract: n is a nonnegative integer, L is a list ( possibly empty ) ; Output contract: ( dropLast n L

Question 5
; Input contract: n is a nonnegative integer, L is a list (possibly empty)
; Output contract: (dropLast n L) is the list L with the last n elements removed (if you try to drop more elements than
; actually exist in L, then everything will be gone and so the empty list would be returned)
; Example: (dropLast 3'(a b c d e f g)) would be '(a b c d) since the last three elements (the e,f,g) were dropped.
; Requirements: do NOT use "let" or "list-ref" or "length", instead use recursion
; Hint: writing the appropriate helper function will make this problem much easier.
(define (dropLast n L))
Below are the tests that need to pass:
;Test Bed
(display "Question 5 Tests
")
(define-test-suite test_sum5
(test-equal? ""(dropLast 0'(a b c d e f g h))'(a b c d e f g h))
(test-equal? ""(dropLast 1'(a b c d e f g h))'(a b c d e f g))
(test-equal? ""(dropLast 2'(a b c d e f g h))'(a b c d e f))
(test-equal? ""(dropLast 3'(a b c d e f g h))'(a b c d e))
(test-equal? ""(dropLast 4'(a b c d e f g h))'(a b c d))
(test-equal? ""(dropLast 5'(a b c d e f g h))'(a b c))
(test-equal? ""(dropLast 6'(a b c d e f g h))'(a b))
(test-equal? ""(dropLast 7'(a b c d e f g h))'(a))
(test-equal? ""(dropLast 8'(a b c d e f g h)) null)
(test-equal? ""(dropLast 9'(a b c d e f g h)) null))
(define q5_score (-10(run-tests test_sum5 'verbose)))
#|

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!