All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jnape.palatable.lambda.functions.builtin.fn1.Tail Maven / Gradle / Ivy

package com.jnape.palatable.lambda.functions.builtin.fn1;

import com.jnape.palatable.lambda.functions.Fn1;

import static com.jnape.palatable.lambda.functions.builtin.fn2.Drop.drop;

/**
 * Returns the tail of an Iterable; the is, an Iterable of all the elements except for the
 * head element. If the input Iterable is empty, the result is also an empty Iterable;
 *
 * @param  the Iterable element type
 */
public final class Tail implements Fn1, Iterable> {

    private static final Tail INSTANCE = new Tail();

    private Tail() {
    }

    @Override
    public Iterable apply(Iterable as) {
        return drop(1, as);
    }

    @SuppressWarnings("unchecked")
    public static  Tail tail() {
        return INSTANCE;
    }

    public static  Iterable tail(Iterable as) {
        return Tail.tail().apply(as);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy