U reduce(T initial_result, U(*next_result)(U, T)) { Node *p = head; U temp = initial_result; if (head != nullptr) { do { temp = next_result(temp, p->value); p = p->next; } while (p != head); } return temp; }
//========================================================================= scx::ScriptRef* SQLiteQuery::script_method(const scx::ScriptAuth& auth, const scx::ScriptRef& ref, const std::string& name, const scx::ScriptRef* args) { if ("exec" == name) { if (!exec(args)) { return scx::ScriptError::new_ref(m_error_string); } // Return 'true' to indicate success return scx::ScriptInt::new_ref(1); } if ("next_result" == name) { if (m_invalid) return scx::ScriptError::new_ref(m_error_string); if (!m_stmt) return scx::ScriptError::new_ref("No statement"); return scx::ScriptInt::new_ref( next_result() ); } return scx::ScriptObject::script_method(auth,ref,name,args); }