public LispObject GetElement(LispObject k) throws Exception {
    LispPtr v = _map.get(new LispPtr(k));

    if (v != null) return v.Get();

    return null;
  }
 public LispPtr Keys() throws Exception {
   LispObject head = LispAtom.New(_env, "List");
   LispPtr p = new LispPtr(head);
   for (Map.Entry<LispPtr, LispPtr> e : _map.entrySet()) {
     p.Get().Set(e.getKey().Get().Copy(true));
     p = p.Get().Next();
   }
   return new LispPtr(LispSubList.New(head));
 }
  LispPtr Head() throws Exception {
    assert (!_map.isEmpty());
    Map.Entry<LispPtr, LispPtr> e = _map.entrySet().iterator().next();

    LispObject p = LispAtom.New(_env, "List");
    LispPtr q = new LispPtr(p);
    q.Get().Set(e.getKey().Get().Copy(true));
    q = q.Get().Next();
    q.Get().Set(e.getValue().Get().Copy(true));

    return new LispPtr(LispSubList.New(p));
  }
示例#4
0
  public boolean Equal(LispObject aOther) throws Exception {
    // next line handles the fact that either one is a string
    if (String() != aOther.String()) return false;

    // So, no strings.
    LispPtr iter1 = SubList();
    LispPtr iter2 = aOther.SubList();
    if (!(iter1 != null && iter2 != null)) return false;

    // check all elements in sublist
    while (iter1.Get() != null && iter2.Get() != null) {
      if (!iter1.Get().Equal(iter2.Get())) return false;

      iter1 = iter1.Get().Next();
      iter2 = iter2.Get().Next();
    }
    // One list longer than the other?
    return iter1.Get() == null && iter2.Get() == null;
  }