Question: Please use code.pyret.org/editor to finish this work. thanks! 3. Using just case analysis and recursion, define a function, called knil, that links a value of
Please use code.pyret.org/editor to finish this work. thanks!
3. Using just case analysis and recursion, define a function, called knil, that links a value of type T onto the *end* of a ListeT>. For example: knil(1, list: 3, 2]) should result in [list: 3, 2, 1]. HINT: Structure your program, as you presumably did previously in 1 and 2, as a case analysis on the input list l. Think recursively in the case when l is a link (f, r), with head or front element f and tail or rest r. What's a recursive way in which to move the new element "a" toward the end of the list, while maintaining the correct structure of the list up to that point? T, l:: List
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
