I think my comments are too long to be considered just comments. I do not want to answer, I just want to give hints. Otherwise, it will defeat the goal.
Repeat my prompts:
a. The second parameter will remain unchanged in your result, so you can just spend time worrying about the first parameter.
b. First you need to know how to add something to an empty list. Ie, you need to know what to do when the first parameter is empty.
from. Then you need to know how to break a non-empty case into a smaller problem adding.
If you donβt know how to create an element, you can start by writing a function that takes (say) an integer and a list of integers and returns a new list with an integer. Here is a function that takes an integer and returns a list containing only one integer:
let list1 k = Item (k, Empty)
One way to think that every time Item appears in your code is to create a new element. Item is called a constructor because it creates an element.
Hope this helps.
source share