sexp
Interface SList
- All Superinterfaces:
- Iterable<SExp>, SExp
- All Known Implementing Classes:
- SEmpty, SNonEmpty
public interface SList
- extends SExp, Iterable<SExp>
SList represents an expression consisting of a list of subexpressions, e.g. (a b c).
The methods of SList offer three patterns for iterating over the subexpressions:
- By removing the first element: use first(), rest(), and isEmpty().
- By indexing down the list: use get() and size().
- By Iterator: use iterator() or the for(var:list) {...} syntax.
isEmpty
boolean isEmpty()
- Returns:
first
SExp first()
- Returns:
- first expression in this list
- Requires:
- this list is not empty
rest
SList rest()
- Returns:
- remaining expressions after removing the first
- Requires:
- this list is not empty
size
int size()
- Returns:
- number of subexpressions, i.e. elements in this list
get
SExp get(int i)
- Returns:
- ith element of this list, numbered from 0
- Requires:
- 0 <= i < size()
iterator
Iterator<SExp> iterator()
- Specified by:
iterator
in interface Iterable<SExp>
- Returns:
- iterator that yields the subexpressions of this list
in order from left to right