///eqv? cellpoint eqv_proc(cellpoint arglst) { check_arglst_len_eq("eqv?", 2, arglst); args_push(car(cdr(arglst))); args_push(car(arglst)); return eqv(); }
int eqv(Value *v1, Value *v2) { switch (v1->tag) { /* case any: return 1; break; */ case nil: CHECK_TAG(v2, nil); return 1; break; case cons: CHECK_TAG(v2, cons); return (eqv(VCAR(v1), VCAR(v2)) && eqv(VCDR(v1), VCDR(v2))); break; case string: CHECK_TAG(v2, string); return (VSLENGTH(v1) == VSLENGTH(v2) && 0 == bcmp(VSDATA(v1), VSDATA(v2), VSLENGTH(v1))); break; case symbol: CHECK_TAG(v2, symbol); return (VSLENGTH(v1) == VSLENGTH(v2) && 0 == bcmp(VSDATA(v1), VSDATA(v2), VSLENGTH(v1))); break; case integer: CHECK_TAG(v2, integer); return (VINTEGER(v1) == VINTEGER(v2)); break; case var: if (VVTAG(v1) != any) CHECK_TAG(v2, VVTAG(v1)); return 1; break; default: /* ??? error */ break; } }
int equal (LISP a, LISP b) /* рекурсивное сравнение */ { if (a == b) return (1); while (istype (a, TPAIR)) { if (! istype (b, TPAIR) || ! equal (car (a), car (b))) return (0); a = cdr (a); b = cdr (b); } return (eqv (a, b)); }
bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& ) { switch( ea.getEventType() ) { case(osgGA::GUIEventAdapter::KEYUP): { if (ea.getKey()==osgGA::GUIEventAdapter::KEY_F6) { // F6 -- Toggle osgOQ testing. _enable = !_enable; EnableQueryVisitor eqv( _enable ); _node.accept( eqv ); return true; } else if (ea.getKey()==osgGA::GUIEventAdapter::KEY_F7) { // F7 -- Toggle display of OQ test bounding volumes _debug = !_debug; DebugDisplayVisitor ddv( _debug ); _node.accept( ddv ); return true; } else if (ea.getKey()==osgGA::GUIEventAdapter::KEY_F8) { // F8 -- Gether stats and display StatisticsVisitor sv; _node.accept( sv ); std::cout << "osgOQ: Stats: numOQNs " << sv.getNumOQNs() << ", numPased " << sv.getNumPassed() << std::endl; return true; } else if (ea.getKey()==osgGA::GUIEventAdapter::KEY_F9) { // F9 -- Remove all OcclusionQueryNodes RemoveOcclusionQueryVisitor roqv; _node.accept( roqv ); return true; } else if (ea.getKey()=='o') { if (osgDB::writeNodeFile( _node, "saved_model.osg" )) osg::notify( osg::ALWAYS ) << "osgOQ: Wrote scene graph to \"saved_model.osg\"" << std::endl; else osg::notify( osg::ALWAYS ) << "osgOQ: Wrote failed for \"saved_model.osg\"" << std::endl; return true; } return false; } default: break; } return false; }
// The member function returns true of item appears in list and false otherwise. bool member( Symbol *item, List *list ) { if(null(list)) { return false; //baseish case } if(eqv(item,car(list))) { return true; //baseish case also }else{ member(item,cdr(list)); //recursion YEAH!!! } }
Value * assqv(Value *key, Value *assoc) { Value *pair; /* cdr on through */ while (VTAG(assoc) == cons) { pair = VCAR(assoc); if (VTAG(pair) == cons && eqv(VCAR(pair), key)) { return pair; } assoc = VCDR(assoc); } return NULL; }
int eqvvector (LISP a, LISP b) /* сравнение векторов */ { LISP *s, *t; int len; assert (a>=0 && a<memsz && mem[a].type==TVECTOR); assert (b>=0 && b<memsz && mem[b].type==TVECTOR); if (mem[a].as.vector.length != mem[b].as.vector.length) return (0); len = mem[a].as.vector.length; s = mem[a].as.vector.array; t = mem[b].as.vector.array; while (--len >= 0) if (! eqv (*s++, *t++)) return (0); return (1); }
bool GenericExpression::equal(const GenericExpression &other) const { if (eqv(other)) { return true; } { const StringExpression *strA = asString(); const StringExpression *strB = other.asString(); if (strA && strB) { // Simple case sensitive, binary safe compare return (strA->length() == strB->length()) && (memcmp(strA->data(), strB->data(), strA->length()) == 0); } } { const VectorExpression *vecA = asVector(); const VectorExpression *vecB = other.asVector(); if (vecA && vecB) { if (vecA->size() != vecB->size()) { return false; } for(unsigned int i = 0; i < vecA->size(); i++) { if (!vecA->item(i)->equal(*vecB->item(i))) { return false; } } return true; } } { const PairExpression *pairA = asPair(); const PairExpression *pairB = other.asPair(); if (pairA && pairB) { if (!pairA->car()->equal(*pairB->car())) { return false; } // Compare the rest of the list // This probably isn't properly tail recursive but I'm writing a Scheme // compiler in Scala so this seems incredibly natural right now return pairA->cdr()->equal(*pairB->cdr()); } } return false; }