/**
 * Given a nested list and an index, return the elements at that index across all nested lists.
 *
 * @param lst A nested list containing elements.
 * @param index The index to access the elements at.
 * @return A list containing the elements at the specified index across all nested lists.
 *
 * Example:
 * getNestedElements(listOf(listOf("a", "b", "c"), listOf("d", "e", "f"), listOf("g", "h", "i")), 1)
 * // Output: ["b", "e", "h"]
 * getNestedElements(listOf(listOf(1, 2), listOf(3, 4, 5), listOf(6, 7, 8, 9)), 2)
 * // Output: [2, 5, 8]
 */
fun getNestedElements(lst: List<List<Any>>, index: Int): List<Any> {

    val nestedElements = mutableListOf<Any>()
    for (nestedList in lst) {
        if (index < nestedList.size) {
            nestedElements.add(nestedList[index])
        }
    }
    return nestedElements
}
/**
 * Given a nested list and an index, return the elements at that index across all nested lists.
 *
 * @param lst A nested list containing elements.
 * @param index The index to access the elements at.
 * @return A list containing the elements at the specified index across all nested lists.
 *
 * Example:
 * getNestedElements(listOf(listOf("a", "b", "c"), listOf("d", "e", "f"), listOf("g", "h", "i")), 1)
 * // Output: ["b", "e", "h"]
 * getNestedElements(listOf(listOf(1, 2), listOf(3, 4, 5), listOf(6, 7, 8, 9)), 2)
 * // Output: [2, 5, 8]
 */
fun getNestedElements(lst: List<List<Any>>, index: Int): List<Any> {
/**
 * Given a nested list and an index, return the elements at that index across all nested lists.
 *
 * @param lst A nested list containing elements.
 * @param index The index to access the elements at.
 * @return A list containing the elements at the specified index across all nested lists.
 *
 * Example:
 * getNestedElements(listOf(listOf("a", "b", "c"), listOf("d", "e", "f"), listOf("g", "h", "i")), 1)
 * // Output: ["b", "e", "h"]
 * getNestedElements(listOf(listOf(1, 2), listOf(3, 4, 5), listOf(6, 7, 8, 9)), 2)
 * // Output: [2, 5, 8]
 */
fun getNestedElements(lst: List<List<Any>>, index: Int): List<Any> {

    val nestedElements = mutableListOf<Any>()
    for (nestedList in lst) {
        if (index < nestedList.size) {
            nestedElements.add(nestedList[index])
        }
    }
    return nestedElements
}