コード例 #1
0
 public <U> FunctionalList<U> map(final Function<T, U> mapping) {
   return isEmpty() ? FunctionalList.<U>nil() : cons(mapping.apply(head()), tail().map(mapping));
 }
コード例 #2
0
 public FunctionalList<T> append(final T element) {
   return isEmpty()
       ? cons(element, FunctionalList.<T>nil())
       : cons(head(), tail().append(element));
 }
コード例 #3
0
 private static <T> FunctionalList<T> fromArray(final T[] items, final int start, final int end) {
   return start == end
       ? FunctionalList.<T>nil()
       : cons(items[start], fromArray(items, start + 1, end));
 }