Jatha Software

org.jatha.dynatype
Class StandardLispCons

java.lang.Object
  extended by org.jatha.dynatype.StandardLispValue
      extended by org.jatha.dynatype.StandardLispConsOrNil
          extended by org.jatha.dynatype.StandardLispCons
All Implemented Interfaces:
Comparable, LispCons, LispConsOrNil, LispValue

public class StandardLispCons
extends StandardLispConsOrNil
implements LispCons


Field Summary
protected  LispValue carCell
           
protected  LispValue cdrCell
           
static boolean DEBUG
           
static long serialVersionUID
           
 
Fields inherited from class org.jatha.dynatype.StandardLispValue
f_lisp
 
Constructor Summary
StandardLispCons()
           
StandardLispCons(Jatha lisp)
           
StandardLispCons(Jatha lisp, LispValue theCar, LispValue theCdr)
           
 
Method Summary
 LispValue append(LispValue otherList)
          Append two lists together.
 LispValue assoc(LispValue index)
          Look up a value in an association list.
 boolean basic_consp()
          Returns Java true if the object is a CONS cell.
 boolean basic_constantp()
          Returns Java true if the object is a constant.
 int basic_length()
          Returns the Java length of a list or string.
 LispValue car()
          Returns the first element of a list.
 LispValue cdr()
          Returns all but the first element of a list.
 LispValue consp()
          Returns T if the object is a CONS cell.
 boolean contains(LispValue object)
          Wrapper for member().
 LispValue copy_list()
          Returns a copy of the top level of a list.
 LispValue copy()
          Returns a full copy of any list, tree, array or table, copying all the leaf elements.
 LispValue eighth()
          Returns the 8th element of a list.
 LispValue equal(LispValue value)
          Returns T if the argument is EQL or if two strings are STRING= or if two trees have EQUAL subtrees.
 LispValue fifth()
          Returns the fifth element of a list, or NIL if the list is shorter than 5 elements.
 LispValue first()
          Returns the first element of a list.
 LispValue fourth()
          Returns the 4th element of a list, or NIL if the list is shorter than 4 elements.
 void internal_prin1_as_cdr(PrintStream os)
           
 void internal_prin1(PrintStream os)
           
 void internal_princ_as_cdr(PrintStream os)
           
 void internal_princ(PrintStream os)
           
 void internal_print_as_cdr(PrintStream os)
           
 void internal_print(PrintStream os)
           
 LispValue last()
          Returns the last cons cell in a list.
 LispValue length()
          Returns a LispInteger containing the length of the list.
 LispValue member(LispValue elt)
          Returns the tail of the list starting at the given element.
 LispValue ninth()
          Returns the ninth element of a list, or NIL if the list is shorter than nine elements.
 LispValue pop()
          Pops a list and returns the first element.
 LispValue push(LispValue value)
          Pushes an element onto a list and returns the list.
 LispValue rassoc(LispValue index)
          Like ASSOC except it matches the CDR of the cell instead of the CAR.
 LispValue remove(LispValue elt)
          Returns a copy of a list without all copies of the given element.
 LispValue rest()
          Synonym for CDR.
 LispValue rplaca(LispValue newCar)
          Replaces the CAR of a CONS cell.
 LispValue rplacd(LispValue newCdr)
          Replaces the CDR of a CONS cell.
 LispValue second()
          Returns the second element of a list or NIL if the list is shorter than two elements.
 LispValue seventh()
          Returns the seventh element of a list or NIL if the list is shorter than seven elements.
 LispValue sixth()
          Returns the sixth element of a list or NIL if the list is shorter than six elements.
 LispValue subst(LispValue newValue, LispValue oldValue)
          Replaces all oldValues in a tree with newValue.
 LispValue tenth()
          Returns the tenth element of a list or NIL if the list is less than ten elements long.
 LispValue third()
          Returns the third element of a list or NIL if the list is less than three elements long.
 Collection toCollection()
          Returns the Lisp value as a Collection.
 String toString()
          toString() returns a printed representation of the form (as printed by (prin1)) in a Java string.
 String toStringAsCdr_internal(long index)
          Counts cdrs so as not to have runaway lists.
 String toStringAsCdr()
           
 LispValue type_of()
           
 LispValue typep(LispValue type)
           
 
Methods inherited from class org.jatha.dynatype.StandardLispConsOrNil
basic_listp, butlast, elt, iterator, listp, nconc, nreverse, position, reverse
 
Methods inherited from class org.jatha.dynatype.StandardLispValue
abs, acos, add, adjustSpecialCount, apply, apropos_print, asin, atan, atan2, atom, basic_atom, basic_bignump, basic_floatp, basic_foreignp, basic_functionp, basic_integerp, basic_keywordp, basic_macrop, basic_null, basic_numberp, basic_stringp, basic_symbolp, bignump, boundp, ceiling, characterp, clrhash, compareTo, concatenate, constantp, cos, cot, csc, degreesToRadians, divide, documentation, elt, eq, eql, equalNumeric, factorial, fboundp, floatp, floor, funcall, functionp, get_specialCount, gethash, gethash, getLisp, greaterThan, greaterThanOrEqual, hash_table_count, hash_table_rehash_size, hash_table_rehash_threshold, hash_table_size, hash_table_test, hashtablep, integerp, internal_getName, keywordp, lessThan, lessThanOrEqual, lisp_null, list, max, min, multiply, negate, neql, nstringCapitalize, nstringDowncase, nstringUpcase, numberp, prin1, princ, print, radiansToDegrees, readFromString, reciprocal, remhash, sec, set_special, setf_documentation, setf_gethash, setf_symbol_function, setf_symbol_plist, setf_symbol_value, setLisp, setPackage, setq, showStackTrace, sin, specialP, sqrt, string, stringCapitalize, stringDowncase, stringEndsWith, stringEq, stringEqual, stringGreaterP, stringGreaterThan, stringGreaterThanOrEqual, stringLeftTrim, stringLeftTrim, stringLessP, stringLessThan, stringLessThanOrEqual, stringNeq, stringNotGreaterP, stringNotLessP, stringp, stringRightTrim, stringRightTrim, stringStartsWith, stringTrim, stringTrim, stringUpcase, substring, substring, subtract, symbol_function, symbol_name, symbol_package, symbol_plist, symbol_value, symbolp, tan, toJava, toJava, toString, toStringShort, toStringShort, toStringSimple, uses, zerop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jatha.dynatype.LispValue
abs, acos, add, adjustSpecialCount, apply, apropos_print, asin, atan, atan2, atom, basic_atom, basic_bignump, basic_floatp, basic_foreignp, basic_functionp, basic_integerp, basic_keywordp, basic_listp, basic_macrop, basic_null, basic_numberp, basic_stringp, basic_symbolp, bignump, boundp, butlast, ceiling, characterp, clrhash, compareTo, concatenate, constantp, cos, cot, csc, degreesToRadians, divide, documentation, elt, elt, eq, eql, equalNumeric, factorial, fboundp, floatp, floor, funcall, functionp, get_specialCount, gethash, gethash, getLisp, greaterThan, greaterThanOrEqual, hash_table_count, hash_table_rehash_size, hash_table_rehash_threshold, hash_table_size, hash_table_test, hashtablep, integerp, internal_getName, iterator, keywordp, lessThan, lessThanOrEqual, lisp_null, list, listp, max, min, multiply, nconc, negate, neql, nreverse, nstringCapitalize, nstringDowncase, nstringUpcase, numberp, position, prin1, princ, print, radiansToDegrees, readFromString, reciprocal, remhash, reverse, sec, set_special, setf_documentation, setf_gethash, setf_symbol_function, setf_symbol_plist, setf_symbol_value, setLisp, setPackage, setq, sin, specialP, sqrt, string, stringCapitalize, stringDowncase, stringEndsWith, stringEq, stringEqual, stringGreaterP, stringGreaterThan, stringGreaterThanOrEqual, stringLeftTrim, stringLeftTrim, stringLessP, stringLessThan, stringLessThanOrEqual, stringNeq, stringNotGreaterP, stringNotLessP, stringp, stringRightTrim, stringRightTrim, stringStartsWith, stringTrim, stringTrim, stringUpcase, substring, substring, subtract, symbol_function, symbol_name, symbol_package, symbol_plist, symbol_value, symbolp, tan, toJava, toJava, toString, toStringShort, toStringShort, toStringSimple, uses, zerop
 

Field Detail

serialVersionUID

public static final long serialVersionUID
See Also:
Constant Field Values

DEBUG

public static boolean DEBUG

carCell

protected LispValue carCell

cdrCell

protected LispValue cdrCell
Constructor Detail

StandardLispCons

public StandardLispCons()

StandardLispCons

public StandardLispCons(Jatha lisp,
                        LispValue theCar,
                        LispValue theCdr)

StandardLispCons

public StandardLispCons(Jatha lisp)
Method Detail

internal_princ

public void internal_princ(PrintStream os)
Specified by:
internal_princ in interface LispValue
Overrides:
internal_princ in class StandardLispValue

internal_princ_as_cdr

public void internal_princ_as_cdr(PrintStream os)
Specified by:
internal_princ_as_cdr in interface LispValue
Overrides:
internal_princ_as_cdr in class StandardLispValue

internal_prin1

public void internal_prin1(PrintStream os)
Specified by:
internal_prin1 in interface LispValue
Overrides:
internal_prin1 in class StandardLispValue

internal_prin1_as_cdr

public void internal_prin1_as_cdr(PrintStream os)
Specified by:
internal_prin1_as_cdr in interface LispValue
Overrides:
internal_prin1_as_cdr in class StandardLispValue

internal_print

public void internal_print(PrintStream os)
Specified by:
internal_print in interface LispValue
Overrides:
internal_print in class StandardLispValue

internal_print_as_cdr

public void internal_print_as_cdr(PrintStream os)
Specified by:
internal_print_as_cdr in interface LispValue
Overrides:
internal_print_as_cdr in class StandardLispValue

basic_consp

public boolean basic_consp()
Description copied from interface: LispValue
Returns Java true if the object is a CONS cell.

Specified by:
basic_consp in interface LispValue
Overrides:
basic_consp in class StandardLispConsOrNil

basic_constantp

public boolean basic_constantp()
Description copied from interface: LispValue
Returns Java true if the object is a constant.

Specified by:
basic_constantp in interface LispValue
Overrides:
basic_constantp in class StandardLispValue

basic_length

public int basic_length()
Description copied from interface: LispValue
Returns the Java length of a list or string.

Specified by:
basic_length in interface LispValue
Overrides:
basic_length in class StandardLispValue

toString

public String toString()
toString() returns a printed representation of the form (as printed by (prin1)) in a Java string.

Specified by:
toString in interface LispValue
Overrides:
toString in class StandardLispValue
Returns:
String The value in a string.

toStringAsCdr_internal

public String toStringAsCdr_internal(long index)
Counts cdrs so as not to have runaway lists.

Specified by:
toStringAsCdr_internal in interface LispValue
Overrides:
toStringAsCdr_internal in class StandardLispValue

toStringAsCdr

public String toStringAsCdr()
Specified by:
toStringAsCdr in interface LispValue
Overrides:
toStringAsCdr in class StandardLispValue

contains

public boolean contains(LispValue object)
Wrapper for member().

Specified by:
contains in interface LispValue
Overrides:
contains in class StandardLispValue
Returns:
true if the object is in the list.

toCollection

public Collection toCollection()
Returns the Lisp value as a Collection. Most useful for lists, which are turned into Collections. But also works for single values.

Specified by:
toCollection in interface LispValue
Overrides:
toCollection in class StandardLispValue

append

public LispValue append(LispValue otherList)
Description copied from interface: LispValue
Append two lists together. The first list is copied.

Specified by:
append in interface LispValue
Overrides:
append in class StandardLispValue

assoc

public LispValue assoc(LispValue index)
Description copied from interface: LispValue
Look up a value in an association list.

Specified by:
assoc in interface LispValue
Overrides:
assoc in class StandardLispValue

car

public LispValue car()
Description copied from interface: LispValue
Returns the first element of a list. CAR of NIL is NIL.

Specified by:
car in interface LispValue
Overrides:
car in class StandardLispValue

cdr

public LispValue cdr()
Description copied from interface: LispValue
Returns all but the first element of a list. CDR of NIL is NIL.

Specified by:
cdr in interface LispValue
Overrides:
cdr in class StandardLispValue

consp

public LispValue consp()
Description copied from interface: LispValue
Returns T if the object is a CONS cell. This is equivalent to asking whether it has a CAR and a CDR and is not NIL.

Specified by:
consp in interface LispValue
Overrides:
consp in class StandardLispValue

copy_list

public LispValue copy_list()
Description copied from interface: LispValue
Returns a copy of the top level of a list. Does not copy the interior branches.

Specified by:
copy_list in interface LispValue
Overrides:
copy_list in class StandardLispValue

copy

public LispValue copy()
Returns a full copy of any list, tree, array or table, copying all the leaf elements. Atoms like symbols, and numbers are not copied. In Java, a string is not mutable so strings are also not copied.

Specified by:
copy in interface LispValue
Overrides:
copy in class StandardLispValue

equal

public LispValue equal(LispValue value)
Description copied from interface: LispValue
Returns T if the argument is EQL or if two strings are STRING= or if two trees have EQUAL subtrees.

Specified by:
equal in interface LispValue
Overrides:
equal in class StandardLispValue

first

public LispValue first()
Description copied from interface: LispValue
Returns the first element of a list. Identical to the CAR function.

Specified by:
first in interface LispValue
Overrides:
first in class StandardLispValue

second

public LispValue second()
Description copied from interface: LispValue
Returns the second element of a list or NIL if the list is shorter than two elements.

Specified by:
second in interface LispValue
Overrides:
second in class StandardLispValue

third

public LispValue third()
Description copied from interface: LispValue
Returns the third element of a list or NIL if the list is less than three elements long.

Specified by:
third in interface LispValue
Overrides:
third in class StandardLispValue

fourth

public LispValue fourth()
Description copied from interface: LispValue
Returns the 4th element of a list, or NIL if the list is shorter than 4 elements.

Specified by:
fourth in interface LispValue
Overrides:
fourth in class StandardLispValue

fifth

public LispValue fifth()
Description copied from interface: LispValue
Returns the fifth element of a list, or NIL if the list is shorter than 5 elements.

Specified by:
fifth in interface LispValue
Overrides:
fifth in class StandardLispValue

sixth

public LispValue sixth()
Description copied from interface: LispValue
Returns the sixth element of a list or NIL if the list is shorter than six elements.

Specified by:
sixth in interface LispValue
Overrides:
sixth in class StandardLispValue

seventh

public LispValue seventh()
Description copied from interface: LispValue
Returns the seventh element of a list or NIL if the list is shorter than seven elements.

Specified by:
seventh in interface LispValue
Overrides:
seventh in class StandardLispValue

eighth

public LispValue eighth()
Description copied from interface: LispValue
Returns the 8th element of a list. If the list is shorter than 8 elements, returns NIL.

Specified by:
eighth in interface LispValue
Overrides:
eighth in class StandardLispValue

ninth

public LispValue ninth()
Description copied from interface: LispValue
Returns the ninth element of a list, or NIL if the list is shorter than nine elements.

Specified by:
ninth in interface LispValue
Overrides:
ninth in class StandardLispValue

tenth

public LispValue tenth()
Description copied from interface: LispValue
Returns the tenth element of a list or NIL if the list is less than ten elements long.

Specified by:
tenth in interface LispValue
Overrides:
tenth in class StandardLispValue

last

public LispValue last()
Description copied from interface: LispValue
Returns the last cons cell in a list. LAST of NIL is NIL.

Specified by:
last in interface LispValue
Overrides:
last in class StandardLispValue

length

public LispValue length()
Returns a LispInteger containing the length of the list. Throws an error on a malformed list, and if the length of the list is greater than *MAX-LIST-LENGTH*.

Specified by:
length in interface LispValue
Overrides:
length in class StandardLispConsOrNil

member

public LispValue member(LispValue elt)
Description copied from interface: LispValue
Returns the tail of the list starting at the given element. Uses EQL as the comparator.

Specified by:
member in interface LispValue
Overrides:
member in class StandardLispValue

pop

public LispValue pop()
Description copied from class: StandardLispValue
Pops a list and returns the first element. NOTE: Because Java's variable values aren't accessible to Jatha, the following doesn't work as expected:
   LispValue l1 = lisp.makeList(A, B);
   l1.pop();   // works correctly, l1 is now (B)
   l1.pop();   // doesn't work correctly.  l1 is now (NIL . NIL)
 
Jatha can't reassign l1 as expected.

However, the following does work:

   LispValue l1 = new LispSymbol(lisp, "L1");
   l1.setq(lisp.makeList(A, B));
   l1.pop();  // works correctly.  The value of L1 is now (B).
   l1.pop();  // works correctly.  The value of L1 is now NIL.
   l1.push(A); // works correctly.  The value of L1 is now (A).
   assert(l1.symbol_value().equal(lisp.makeList(A)) == lisp.T);
 

Specified by:
pop in interface LispValue
Overrides:
pop in class StandardLispConsOrNil
Returns:
the first element of the list

push

public LispValue push(LispValue value)
Description copied from class: StandardLispValue
Pushes an element onto a list and returns the list. NOTE: Because Java's variable values aren't accessible to Jatha, the following doesn't work as expected:
   LispValue l1 = LispValue.NIL;
   l1.push(A); // doesn't work correctly.  l1 is still NIL.
   l1 = l1.push(A);  // works correctly.
 
Jatha can't reassign l1 as expected.

However, the following does work:

   LispValue l1 = new LispSymbol("L1");
   l1.setq(LispValue.NIL);
   l1.push(B); // works correctly.  The value of L1 is now (B).
   l1.push(A); // works correctly.  The value of L1 is now (A B).
   assert(l1.symbol_value().equal(LispValueFactory.makeList(A, B)) == LispValue.T);
 

Specified by:
push in interface LispValue
Overrides:
push in class StandardLispValue
Returns:
the new list.

rassoc

public LispValue rassoc(LispValue index)
Description copied from interface: LispValue
Like ASSOC except it matches the CDR of the cell instead of the CAR.

Specified by:
rassoc in interface LispValue
Overrides:
rassoc in class StandardLispValue

rest

public LispValue rest()
Description copied from class: StandardLispValue
Synonym for CDR.

Specified by:
rest in interface LispValue
Overrides:
rest in class StandardLispValue

remove

public LispValue remove(LispValue elt)
Description copied from interface: LispValue
Returns a copy of a list without all copies of the given element.

Specified by:
remove in interface LispValue
Overrides:
remove in class StandardLispValue

rplaca

public LispValue rplaca(LispValue newCar)
Description copied from interface: LispValue
Replaces the CAR of a CONS cell.

Specified by:
rplaca in interface LispValue
Overrides:
rplaca in class StandardLispValue

rplacd

public LispValue rplacd(LispValue newCdr)
Description copied from interface: LispValue
Replaces the CDR of a CONS cell.

Specified by:
rplacd in interface LispValue
Overrides:
rplacd in class StandardLispValue

subst

public LispValue subst(LispValue newValue,
                       LispValue oldValue)
Description copied from interface: LispValue
Replaces all oldValues in a tree with newValue. The default test is EQL.

Specified by:
subst in interface LispValue
Overrides:
subst in class StandardLispValue

type_of

public LispValue type_of()
Specified by:
type_of in interface LispValue
Overrides:
type_of in class StandardLispValue

typep

public LispValue typep(LispValue type)
Specified by:
typep in interface LispValue
Overrides:
typep in class StandardLispValue

Jatha Software