/*
 * Copyright 2012-2014 Institut National des Sciences Appliquées de Lyon (INSA-Lyon)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package gololang;

/**
 * Structure having a head and a tail.
 * <p>
 * This interface can be used to define any recursive sequence of object,
 * such as lists or generators. It is well suited to recursive algorithms, and
 * thus can be seen as an alternative to the {@code Iterable} interface.
 * <p>
 * For example, one can compute the size of such an object with:
 * <pre>
 * static int size(HeadTail<?> o) {
 *   if (o.isEmpty()) { return 0; }
 *   return 1 + size(o.tail());
 * }
 * </pre>
 * or in Golo:
 * <pre>
 * function size = |ht| -> match {
 *   when ht: isEmpty then 0
 *   otherwhise 1 + size(ht: tail())
 * }
 * </pre>
 * <p>
 * Note that the {@code size} method is not provided since this interface
 * can be implemented by infinite generators.
 * <p>
 * A {@code List} augmentation is provided, as well as corresponding special
 * methods on arrays ({@code Object[]}/{@code array[]})
 */
public interface HeadTail<T> {
  /**
   * Returns the first element of the collection.
   */
  T head();

  /**
   * Returns a new {@code HeadTail} containing the rest of the elements.
   */
  HeadTail<T> tail();

  /**
   * Checks if the structure is empty.
   */
  boolean isEmpty();
}

@@ -1219,16 +1219,18 @@
  isEmpty
+()
  then 0%0A
@@ -1548,16 +1548,82 @@
 ray%5B%5D%7D)%0A
+ *%0A * @param %3CE%3E the type of the elements held in this structure.%0A
  */%0Apubl
@@ -1648,13 +1648,14 @@
 ail%3C
-T
+E
 %3E %7B%0A
+%0A
   /*
@@ -1661,23 +1661,64 @@
 **%0A   * 
-R
+Get the head of the structure.%0A   *%0A   * @r
 eturn
-s
  the fir
@@ -1739,18 +1739,60 @@
 the 
-collection
+structure, or %7B@code null%7D if the structure is empty
 .%0A  
@@ -1797,17 +1797,17 @@
    */%0A  
-T
+E
  head();
@@ -1823,15 +1823,191 @@
   * 
-Returns
+Get the tail of the structure.%0A   * %3Cp%3E%0A   * To be side effect free, this method should return a deep copy of the original structure or an%0A   * immutable view on it.%0A   *%0A   * @return
  a n
@@ -2041,23 +2041,65 @@
 ing 
+all 
 the 
-r
 e
+lements but the fir
 st
+,
  o
-f the
+r a empty one%0A   * if no
  ele
@@ -2103,16 +2103,24 @@
 elements
+ remains
 .%0A   */%0A
@@ -2130,17 +2130,17 @@
 eadTail%3C
-T
+E
 %3E tail()
@@ -2177,32 +2177,133 @@
 ructure is empty
+ or not.%0A   *%0A   * @return %7B@code true%7D if the structure contains no element, %7B@code false%7D otherwise
 .%0A   */%0A  boolea

Improve javadoc.