Implement a singly linked list as a functional data structure in Kotlin. As discussed in the class, the list should be a sealed class with enclosed classes to construct a list, including construction of an empty list. The following methods should be available for a singly linked list: 1. modifyListHead() method to replace the head of the list with a different element. This function accepts an input list and an input variable, and returns a list where the head of the input list has been replaced with the input variable. For example, calling modifyListHead(exList, 10) where exList = (1,2,3,4,5) would return (10,2,3,4,5). 2. dropFromList() method to drop the first n elements from the list. This function accepts an input list and a value for n, and returns a list with the first n elements dropped. For example, calling dropFromList(exList,1) where exList = (1,2,3,4,5) would return (2,3,4,5). 3. sumTwoLists() method that accepts two lists and adds corresponding elements of each list. This function accepts two input lists and returns their sum as illustrated in the example below. For two input lists (1,2,3) and (4,5,6), this function returns (5,7,9) 4. multiplyTwoLists() method that accepts two lists and multiplies corresponding elements in the same way sumTwoLists() adds elements of two arrays. NB: Solution that I earlier got showed some errors when tried to run it. I am also sharing the solution below: sealed class SinglyLinkedList { object Empty : SinglyLinkedList() data class Cons(val head: T, val tail: SinglyLinkedList) : SinglyLinkedList() } fun modifyListHead(list: SinglyLinkedList, newHead: T): SinglyLinkedList = when (list) { is SinglyLinkedList.Empty -> SinglyLinkedList.Empty is SinglyLinkedList.Cons -> SinglyLinkedList.Cons(newHead, list.tail) } fun dropFromList(list: SinglyLinkedList, n: Int): SinglyLinkedList = when (list) { is SinglyLinkedList.Empty -> SinglyLinkedList.Empty is SinglyLinkedList.Cons -> if (n == 0) list else dropFromList(list.tail, n - 1) } fun sumTwoLists(list1: SinglyLinkedList, list2: SinglyLinkedList): SinglyLinkedList = when { list1 is SinglyLinkedList.Empty && list2 is SinglyLinkedList.Empty -> SinglyLinkedList.Empty list1 is SinglyLinkedList.Empty -> list2 list2 is SinglyLinkedList.Empty -> list1 else -> SinglyLinkedList.Cons(list1.head + list2.head, sumTwoLists(list1.tail, list2.tail)) } fun multiplyTwoLists(list1: SinglyLinkedList, list2: SinglyLinkedList): SinglyLinkedList = when { list1 is SinglyLinkedList.Empty || list2 is SinglyLinkedList.Empty -> SinglyLinkedList.Empty else -> SinglyLinkedList.Cons(list1.head * list2.head, multiplyTwoLists(list1.tail, list2.tail)) } fun main(){ val exList = linkedListOf(1, 2, 3, 4, 5) println(exList) // Output: 1 2 3 4 5 val modifiedList = exList.modifyListHead(10) println(modifiedList) // Output: 10 2 3 4 5 val droppedList = exList.dropFromList(1) println(droppedList) // Output: 2 3 4 5 val list1 = linkedListOf(1, 2, 3) val list2 = linkedListOf(4, 5, 6) val sumList = list.