25 #include <opencog/atomspace/atom_types.h>
30 using namespace opencog;
46 throw InvalidParamException(TRACE_INFO,
"Expecting a FoldLink");
56 throw InvalidParamException(TRACE_INFO,
"Expecting a FoldLink");
65 throw InvalidParamException(TRACE_INFO,
"Expecting a FoldLink");
77 #define DO_RETURN(result) { \
78 if (not _atomTable) return (result); \
79 AtomSpace* as = _atomTable->getAtomSpace(); \
80 return as->add_atom(result); \
133 bool did_reduce =
false;
140 Type t = h->getType();
151 Handle redh = fff->reduce();
156 reduct.push_back(redh);
170 size_t osz = reduct.size();
181 for (
size_t i = 0; i < osz-1; i++)
183 const Handle& hi = reduct[i];
187 const Handle& hj = reduct[j];
192 bool do_kons = (it == jt);
197 LinkCast(hj)->getOutgoingAtom(0) == hi);
208 for (
size_t k=0; k < osz; k++)
211 rere.push_back(reduct[k]);
213 rere.push_back(cons);
215 rere.push_back(reduct[k]);
AtomSpace * getAtomSpace(void)
virtual Handle kons(const Handle &, const Handle &)=0
std::vector< Handle > HandleSeq
a list of handles
static LinkPtr factory(LinkPtr)
FoldLink(Type, const HandleSeq &oset, TruthValuePtr tv=TruthValue::NULL_TV(), AttentionValuePtr av=AttentionValue::DEFAULT_AV())
std::shared_ptr< TruthValue > TruthValuePtr
std::shared_ptr< AttentionValue > AttentionValuePtr
std::shared_ptr< FunctionLink > FunctionLinkPtr
ClassServer & classserver(ClassServerFactory *=ClassServer::createInstance)
#define DO_RETURN(result)
static FunctionLinkPtr FunctionLinkCast(const Handle &h)
static LinkPtr LinkCast(const Handle &h)
unsigned short Type
type of Atoms, represented as short integer (16 bits)
virtual Handle reduce(void)
Handle add_atom(AtomPtr atom, bool async=false)