/**
 * Given a list of tuples representing veterinary data, replace a specific element in a tuple at a given index with a new name.
 *
 * @param vetData The veterinary data containing information about animals.
 * @param oldName The name to be replaced.
 * @param newName The new name to replace the old name.
 * @param index The index of the element within each tuple to be replaced.
 * @return The updated veterinary data with the replaced name.
 */
fun sliceAndReplace(vetData: List<Pair<String, String>>, oldName: String, newName: String, index: Int): List<Pair<String, String>> {

    val updatedVetData = mutableListOf<Pair<String, String>>()
    for (data in vetData) {
        // Slicing the tuple to get the elements before and after the element to be replaced
        val before = data.first
        val after = data.second
        // Replacing the old name with the new name
        val updatedTuple = Pair(before, if (index == 0) newName else after)
        updatedVetData.add(updatedTuple)
    }
    return updatedVetData
}
/**
 * Given a list of tuples representing veterinary data, replace a specific element in a tuple at a given index with a new name.
 *
 * @param vetData The veterinary data containing information about animals.
 * @param oldName The name to be replaced.
 * @param newName The new name to replace the old name.
 * @param index The index of the element within each tuple to be replaced.
 * @return The updated veterinary data with the replaced name.
 */
fun sliceAndReplace(vetData: List<Pair<String, String>>, oldName: String, newName: String, index: Int): List<Pair<String, String>> {
/**
 * Given a list of tuples representing veterinary data, replace a specific element in a tuple at a given index with a new name.
 *
 * @param vetData The veterinary data containing information about animals.
 * @param oldName The name to be replaced.
 * @param newName The new name to replace the old name.
 * @param index The index of the element within each tuple to be replaced.
 * @return The updated veterinary data with the replaced name.
 */
fun sliceAndReplace(vetData: List<Pair<String, String>>, oldName: String, newName: String, index: Int): List<Pair<String, String>> {

    val updatedVetData = mutableListOf<Pair<String, String>>()
    for (data in vetData) {
        // Slicing the tuple to get the elements before and after the element to be replaced
        val before = data.first
        val after = data.second
        // Replacing the old name with the new name
        val updatedTuple = Pair(before, if (index == 0) newName else after)
        updatedVetData.add(updatedTuple)
    }
    return updatedVetData
}