Question: Problem 3 (3 points) write an F# program lengthsort to sort a list of lists according the lengths of the element lists such that short


Problem 3 (3 points) write an F# program lengthsort to sort a list of lists according the lengths of the element lists such that short lists first, longer lists later. > lengthsort [[2;3]; [1;2;3;4];[1;2;4;5;6]:[2;3;4]:[3]]; val it : int 1ist list Hint: Use List.map to construct a tuple list from the given list such that the first element is the length of the element list, e.g [[2;3];[1;2;3;4]:[1;2:4;5;6]:[2;3:4];[3]] becomes [ (2, [2;3]); (4, [1;2;3;4]); (5, [1;2;4;5;6]); (3,[2;3;4]);(1, [3] Write a function to sort the final result. Problem 3 (3 points) write an F# program lengthsort to sort a list of lists according the lengths of the element lists such that short lists first, longer lists later. > lengthsort [[2;3]; [1;2;3;4];[1;2;4;5;6]:[2;3;4]:[3]]; val it : int 1ist list Hint: Use List.map to construct a tuple list from the given list such that the first element is the length of the element list, e.g [[2;3];[1;2;3;4]:[1;2:4;5;6]:[2;3:4];[3]] becomes [ (2, [2;3]); (4, [1;2;3;4]); (5, [1;2;4;5;6]); (3,[2;3;4]);(1, [3] Write a function to sort the final result
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
