private <K> FunctionalMultiMap<K, T> groupIntoMap( final FunctionalMultiMap<K, T> map, final Function<T, K> groupingFunction, FunctionalList<T> values) { return values.isEmpty() ? map : groupIntoMap( map.put(groupingFunction.apply(values.head()), values.head()), groupingFunction, values.tail()); }
public T firstMatch(final Function<T, Boolean> matcher) { return isEmpty() ? null : matcher.apply(head()) ? head() : tail().firstMatch(matcher); }
public FunctionalList<T> dropWhile(final Function<T, Boolean> condition) { return isEmpty() ? this : condition.apply(head()) ? tail().dropWhile(condition) : this; }
public <U> FunctionalList<U> map(final Function<T, U> mapping) { return isEmpty() ? FunctionalList.<U>nil() : cons(mapping.apply(head()), tail().map(mapping)); }