name.panitz.eliza
Class LiImpl<a>

java.lang.Object
  extended by name.panitz.eliza.LiImpl<a>
All Implemented Interfaces:
Li<a>
Direct Known Subclasses:
Map

public class LiImpl<a>
extends java.lang.Object
implements Li<a>

A concrete implementation of abstract class Li.


Constructor Summary
LiImpl()
           
LiImpl(a x, Li<a> xs)
           
 
Method Summary
 Li<a> append(Li<a> that)
          Appends two list.
 Li<a> concat(Li<a> that)
          Just another name for method append
static
<b> Li<b>
cons(b x, Li<b> xs)
           
 Li<a> drop(int i)
          Removes the first i elements from a list.
static
<b> Li<b>
empty()
           
 Li<a> filter(FilterCondition<a> cond)
          Creates a list with all elements that fullfill the condition.
 a head()
          Returns the first element of this list.
 boolean isEmpty()
          Tests, if the list contains some element.
 int length()
           
 Li<a> reverse()
          Reverses the element order of the list.
 void rotate()
          Mutates this list, by appending first element as last.
 Li<a> tail()
          Returns the list after the first element has been skipped.
 Li<Li<a>> tails()
          Makes a list of lists of all taillists.
 java.lang.String toString()
           
 java.lang.String unwords()
          Makes a list to a String adding whitespace between the list elements.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LiImpl

public LiImpl()

LiImpl

public LiImpl(a x,
              Li<a> xs)
Method Detail

empty

public static <b> Li<b> empty()

cons

public static <b> Li<b> cons(b x,
                             Li<b> xs)

isEmpty

public boolean isEmpty()
Description copied from interface: Li
Tests, if the list contains some element.

Specified by:
isEmpty in interface Li<a>
Returns:
true if no element is contained in the list.

head

public a head()
Description copied from interface: Li
Returns the first element of this list.

Specified by:
head in interface Li<a>
Returns:
from element.

tail

public Li<a> tail()
Description copied from interface: Li
Returns the list after the first element has been skipped.

Specified by:
tail in interface Li<a>
Returns:
the tail (rest) of the list, which follows first element.

rotate

public void rotate()
Description copied from interface: Li
Mutates this list, by appending first element as last.

Specified by:
rotate in interface Li<a>

filter

public Li<a> filter(FilterCondition<a> cond)
Description copied from interface: Li
Creates a list with all elements that fullfill the condition.

Specified by:
filter in interface Li<a>
Parameters:
cond - Condition to test if element is to be in result list.
Returns:
list with elements that fullfill condition.

length

public int length()
Specified by:
length in interface Li<a>
Returns:
the number of elements in this list.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

append

public Li<a> append(Li<a> that)
Description copied from interface: Li
Appends two list. Thus not modify this or that.

Specified by:
append in interface Li<a>
Parameters:
that - list which is appended to this for creating result
Returns:
a new list which is the concatenation of this with that.

concat

public Li<a> concat(Li<a> that)
Description copied from interface: Li
Just another name for method append

Specified by:
concat in interface Li<a>
Returns:
a new list which is the concatenation of this with that.

tails

public Li<Li<a>> tails()
Description copied from interface: Li
Makes a list of lists of all taillists. example: for the list ("this","is","a","test") this produces: (("this","is","a","test"),("is","a","test"),("a","test"),("test"))

Specified by:
tails in interface Li<a>
Returns:
a list of lists, which contains all list obtained from this list through several calls of tail().

drop

public Li<a> drop(int i)
Description copied from interface: Li
Removes the first i elements from a list.

Specified by:
drop in interface Li<a>
Parameters:
i - a positive number of elements to be skipped from the beginning of the list.
Returns:
this list with i elements dropped by tail calls.

reverse

public Li<a> reverse()
Description copied from interface: Li
Reverses the element order of the list. example: ("a","b","c") gets ("c","b","a")

Specified by:
reverse in interface Li<a>
Returns:
a new list with reversed element order of this list.

unwords

public java.lang.String unwords()
Description copied from interface: Li
Makes a list to a String adding whitespace between the list elements. This is a reverse function to ListUtil.words. example: unwords for a list: ("this","is","a","test") produces the String: "this is a test"

Specified by:
unwords in interface Li<a>
Returns:
a string which concatenates the Strings of this list with whitespace characters.