/**
 * This exercise focuses on copying lists and modifying elements using list comprehensions.
 *
 * You are given a list of animals in their scientific order. However, the names of some animals have to be modified
 * based on certain conditions. Your task is to create a modified copy of the given list with the following rules:
 * - The names of animals that start with a vowel should be capitalized.
 * - The names of animals that end with 'y' should be replaced with 'elephant'.
 * - The names of animals that have exactly four letters should be replaced with 'giraffe'.
 *
 * @param animalList A list of strings representing names of animals.
 * @return A modified copy of the animal list based on the given rules.
 */
fun modifyAnimalList(animalList: List<String>): List<String> {

    return animalList.map { animal ->
        when {
            animal.first().toLowerCase() in listOf('a', 'e', 'i', 'o', 'u') -> animal.toUpperCase()
            animal.last().toLowerCase() == 'y' -> "ELEPHANT"
            animal.length == 4 -> "GIRAFFE"
            else -> animal
        }
    }
}
/**
 * This exercise focuses on copying lists and modifying elements using list comprehensions.
 *
 * You are given a list of animals in their scientific order. However, the names of some animals have to be modified
 * based on certain conditions. Your task is to create a modified copy of the given list with the following rules:
 * - The names of animals that start with a vowel should be capitalized.
 * - The names of animals that end with 'y' should be replaced with 'elephant'.
 * - The names of animals that have exactly four letters should be replaced with 'giraffe'.
 *
 * @param animalList A list of strings representing names of animals.
 * @return A modified copy of the animal list based on the given rules.
 */
fun modifyAnimalList(animalList: List<String>): List<String> {
/**
 * This exercise focuses on copying lists and modifying elements using list comprehensions.
 *
 * You are given a list of animals in their scientific order. However, the names of some animals have to be modified
 * based on certain conditions. Your task is to create a modified copy of the given list with the following rules:
 * - The names of animals that start with a vowel should be capitalized.
 * - The names of animals that end with 'y' should be replaced with 'elephant'.
 * - The names of animals that have exactly four letters should be replaced with 'giraffe'.
 *
 * @param animalList A list of strings representing names of animals.
 * @return A modified copy of the animal list based on the given rules.
 */
fun modifyAnimalList(animalList: List<String>): List<String> {

    return animalList.map { animal ->
        when {
            animal.first().toLowerCase() in listOf('a', 'e', 'i', 'o', 'u') -> animal.toUpperCase()
            animal.last().toLowerCase() == 'y' -> "ELEPHANT"
            animal.length == 4 -> "GIRAFFE"
            else -> animal
        }
    }
}