Question: F# has a predened list datatype. Strictly speaking, however, it is not necessary, For instance, integer lists could be simulated by the following user dened

F# has a predened list datatype. Strictly speaking, however, it is not necessary, For instance, integer lists could be simulated by the following user dened datatype type ilist = E | L of int * ilist where the constructor E stands for the empty list and the constructor L builds a new list by adding a number in front of another list. Then one can represent, say, a list with elements 1,4,6,7, in that order, with the ilist value L(1, L(4, L(6, L(7, E)))). 1 Using pattern matching and recursion, implement the following functions manipulating ilist values  F# has a predened list datatype. Strictly speaking, however, it is

4. Write an F# function remove: int-> ilist-> ilist which, given an integer x and a list l, "removes" all the occurrences of x from l, that is, returns a list containing (in the same order) all and only the elements of l that differ from x. For example, remove 2 (L(1, L(2, L(3, L(3, L(2, E)))))) sL(1, L(3, L(3, E))); remove 5 (L(1, L(2, L(3, )))) is (L(1, L(2, L(3, E)))). 5. Write an F# function move: ilist-> ilist-> ilist which takes two lists and returns the result of inserting the values of the first list into the second, in reverse order. For example, move (L(1, L(2, L(3, E)))) (L(7,E)) is L(3, L(2, L(1, L(7,E))))

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 Databases Questions!