/**
 * Given a list of species, filter out the species that are not within the specified age range.
 *
 * @param species A list of maps representing different species. Each map contains
 *                the keys 'name' and 'age', where 'name' is the name of the species and 'age' is
 *                the age of the species.
 * @param minAge The minimum age required for a species to be included in the filtered list. Defaults to 0.
 * @param maxAge The maximum age allowed for a species. If no maximum age is specified, all species
 *               with age greater than or equal to the minimum age will be included in the filtered list.
 * @return A list of species maps that satisfy the given age range condition.
 */
fun filterSpeciesWithAge(species: List<Map<String, Any>>, minAge: Int = 0, maxAge: Int? = null): List<Map<String, Any>> {

    return species.filter { s ->
        minAge <= s["age"] as Int && (s["age"] as Int) <= (maxAge ?: s["age"] as Int)
    }
}
/**
 * Given a list of species, filter out the species that are not within the specified age range.
 *
 * @param species A list of maps representing different species. Each map contains
 *                the keys 'name' and 'age', where 'name' is the name of the species and 'age' is
 *                the age of the species.
 * @param minAge The minimum age required for a species to be included in the filtered list. Defaults to 0.
 * @param maxAge The maximum age allowed for a species. If no maximum age is specified, all species
 *               with age greater than or equal to the minimum age will be included in the filtered list.
 * @return A list of species maps that satisfy the given age range condition.
 */
fun filterSpeciesWithAge(species: List<Map<String, Any>>, minAge: Int = 0, maxAge: Int? = null): List<Map<String, Any>> {
/**
 * Given a list of species, filter out the species that are not within the specified age range.
 *
 * @param species A list of maps representing different species. Each map contains
 *                the keys 'name' and 'age', where 'name' is the name of the species and 'age' is
 *                the age of the species.
 * @param minAge The minimum age required for a species to be included in the filtered list. Defaults to 0.
 * @param maxAge The maximum age allowed for a species. If no maximum age is specified, all species
 *               with age greater than or equal to the minimum age will be included in the filtered list.
 * @return A list of species maps that satisfy the given age range condition.
 */
fun filterSpeciesWithAge(species: List<Map<String, Any>>, minAge: Int = 0, maxAge: Int? = null): List<Map<String, Any>> {

    return species.filter { s ->
        minAge <= s["age"] as Int && (s["age"] as Int) <= (maxAge ?: s["age"] as Int)
    }
}