| java.lang.Object jsint.Pair
Pair | public class Pair implements java.io.Serializable,jscheme.SchemePair(Code) | | A Pair has two fields, first and rest (sometimes called car and cdr).
The empty list is represented as a Pair, with both fields empty.
(In Scheme it is an error to ask access those fields, but we don't complain.)
author: Peter Norvig, Copyright 1998, peter@norvig.com, license author: subsequently modified by Jscheme project members author: licensed under zlib licence (see license.txt) |
Field Summary | |
final public static Pair | EMPTY The empty list. | public Object | first The first element of the pair. | public Object | rest The other element of the pair. |
Constructor Summary | |
public | Pair(Object first, Object rest) Build a pair from two components. |
EMPTY | final public static Pair EMPTY(Code) | | The empty list. It's first and rest fields are also EMPTY. *
|
first | public Object first(Code) | | The first element of the pair. *
|
rest | public Object rest(Code) | | The other element of the pair. *
|
equals | public boolean equals(Object that)(Code) | | Two pairs are equal if their first and rest fields are (equal?). *
|
first | public Object first()(Code) | | Return the second element of a list. *
|
getFirst | public Object getFirst()(Code) | | Return the first element of a list. *
|
getRest | public Object getRest()(Code) | | Return the second element of a list. *
|
hashCode | public int hashCode()(Code) | | Lists that are .equals have the same .hashCode(). *
|
isEmpty | public boolean isEmpty()(Code) | | |
length | public int length()(Code) | | The length of a proper list. *
|
listTail | public Object listTail(int n)(Code) | | Find the nth tail of a list, zero-based. *
|
nth | public Object nth(int n)(Code) | | Find the nth element of a list, zero-based *
|
rest | public Object rest()(Code) | | Return the second element of a list. *
|
reverse | public Object reverse()(Code) | | Reverse the elements of a list. *
|
second | public Object second()(Code) | | Return the second element of a list. *
|
stringifyPair | public StringBuffer stringifyPair(boolean quoted, StringBuffer buf)(Code) | | Build up a String representation of the Pair in a StringBuffer. *
|
third | public Object third()(Code) | | Return the third element of a list. *
|
toString | public String toString()(Code) | | Return a String representation of the pair. *
|
|
|