/**
 * Given two lists, list1 and list2, this function returns a new list that contains elements from both lists
 * based on certain conditions:
 * - If the length of list1 is less than or equal to 4, it returns a new list containing the first half of list1.
 * - If the length of list2 is greater than 6, it returns a new list containing the last 3 elements of list2.
 * - If neither of the above conditions are met, it returns a new list containing the middle element of list1
 *   and the first element of list2.
 *
 * @param list1 a list of elements
 * @param list2 a list of elements
 * @param num an integer representing the number of slices to perform
 * @return a list containing elements from list1 and list2 based on the conditions mentioned above
 */
fun nestedIfSlicing(list1: List<Any>, list2: List<Any>, num: Int): List<Any> {

    return when {
        list1.size <= 4 -> list1.subList(0, list1.size / 2)
        list2.size > 6 -> list2.subList(list2.size - 3, list2.size)
        else -> listOf(list1[list1.size / 2], list2[0])
    }
}
/**
 * Given two lists, list1 and list2, this function returns a new list that contains elements from both lists
 * based on certain conditions:
 * - If the length of list1 is less than or equal to 4, it returns a new list containing the first half of list1.
 * - If the length of list2 is greater than 6, it returns a new list containing the last 3 elements of list2.
 * - If neither of the above conditions are met, it returns a new list containing the middle element of list1
 *   and the first element of list2.
 *
 * @param list1 a list of elements
 * @param list2 a list of elements
 * @param num an integer representing the number of slices to perform
 * @return a list containing elements from list1 and list2 based on the conditions mentioned above
 */
fun nestedIfSlicing(list1: List<Any>, list2: List<Any>, num: Int): List<Any> {
/**
 * Given two lists, list1 and list2, this function returns a new list that contains elements from both lists
 * based on certain conditions:
 * - If the length of list1 is less than or equal to 4, it returns a new list containing the first half of list1.
 * - If the length of list2 is greater than 6, it returns a new list containing the last 3 elements of list2.
 * - If neither of the above conditions are met, it returns a new list containing the middle element of list1
 *   and the first element of list2.
 *
 * @param list1 a list of elements
 * @param list2 a list of elements
 * @param num an integer representing the number of slices to perform
 * @return a list containing elements from list1 and list2 based on the conditions mentioned above
 */
fun nestedIfSlicing(list1: List<Any>, list2: List<Any>, num: Int): List<Any> {

    return when {
        list1.size <= 4 -> list1.subList(0, list1.size / 2)
        list2.size > 6 -> list2.subList(list2.size - 3, list2.size)
        else -> listOf(list1[list1.size / 2], list2[0])
    }
}