Question: Question 5 ; Input contract: n is a nonnegative integer, L is a list ( possibly empty ) ; Output contract: ( dropLast n L
Question
; 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 a b c d e f g would be a b c d since the last three elements the efg were dropped.
; Requirements: do NOT use "let" or "listref" 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 Tests
definetestsuite testsum
testequal? dropLast a b c d e f g ha b c d e f g h
testequal? dropLast a b c d e f g ha b c d e f g
testequal? dropLast a b c d e f g ha b c d e f
testequal? dropLast a b c d e f g ha b c d e
testequal? dropLast a b c d e f g ha b c d
testequal? dropLast a b c d e f g ha b c
testequal? dropLast a b c d e f g ha b
testequal? dropLast a b c d e f g ha
testequal? dropLast a b c d e f g h null
testequal? dropLast a b c d e f g h null
define qscore runtests testsum 'verbose
#
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
