vector->put (pos, e);
}
+MNode* MNode::vectorDel (size_t from, size_t to) {
+ if (type != MC_VECTOR)
+ throw (uErrorWrongType );
+ MNode* ans = vector->get (from);
+ size_t n = vector->size ();
+ ++ to;
+ if (from < to) {
+ for (; to < n; ++ from, ++ to) {
+ vector->put (from, vector->get (to));
+ }
+ vector->resize (from);
+ }
+ return ans;
+}
+
void MNode::vectorPush (MNode* e) {
if (type != MC_VECTOR)
throw (uErrorWrongType );
table->setVar (name, e);
}
+MNode* MNode::tableDel (const ustring& name) {
+ if (type != MC_TABLE)
+ throw (uErrorWrongType );
+ MNode* ans = table->getVar (name);
+ table->eraseVar (name);
+ return ans;
+}
+
double MNode::to_double () {
switch (type) {
case MNode::MC_NIL:
MNode* vectorGet (size_t pos);
size_t vectorSize ();
void vectorPut (size_t pos, MNode* e);
+ MNode* vectorDel (size_t from, size_t to);
void vectorPush (MNode* e);
MNode* vectorPop ();
void vectorResize (size_t pos);
MNode* tableGet (const ustring& name);
void tablePut (const ustring& name, MNode* e);
+ MNode* tableDel (const ustring& name);
double to_double ();
int to_int () {
return (int)to_double ();
}
/*DOC:
+===vector-del===
+ (vector-del VECTOR FROM [TO]) -> VALUE
+
+*/
+//#AFUNC vector-del ml_vector_del
+//#WIKIFUNC vector-del
+MNode* ml_vector_del (MNode* cell, MlEnv* mlenv) {
+ MNode* arg = cell->cdr ();
+ MNodePtr vec;
+ int from, to;
+
+ if (! arg)
+ throw (uErrorWrongNumber);
+ vec = eval (arg->car (), mlenv);
+ nextNodeNonNil (arg);
+ from = eval_int (arg->car (), mlenv);
+ nextNode (arg);
+ if (arg) {
+ to = eval_int (arg->car (), mlenv);
+ nextNode (arg);
+ } else {
+ to = from;
+ }
+ if (arg)
+ throw (uErrorWrongNumber);
+
+ if (! isVector (vec ()))
+ throw (uErrorWrongType);
+
+ return vec ()->vectorDel (from, to);
+}
+
+/*DOC:
===vector-push===
(vector-push VECTOR VALUE) -> VALUE
}
/*DOC:
+===table-del===
+ (table-del TABLE NAME) -> VALUE
+
+*/
+//#AFUNC table-del ml_table_del
+//#WIKIFUNC table-del
+MNode* ml_table_del (MNode* cell, MlEnv* mlenv) {
+ MNode* arg = cell->cdr ();
+ MNodePtr tbl;
+ ustring name;
+
+ if (! arg)
+ throw (uErrorWrongNumber);
+ tbl = eval (arg->car (), mlenv);
+ nextNodeNonNil (arg);
+ name = eval_str (arg->car (), mlenv);
+ nextNode (arg);
+ if (arg)
+ throw (uErrorWrongNumber);
+
+ if (! isTable (tbl ()))
+ throw (uErrorWrongType);
+ return tbl ()->tableDel (name);
+}
+
+/*DOC:
===table-append===
(table-append TABLE1 TABLE2...) -> TABLE1
MNode* ml_vector_back (MNode* cell, MlEnv* mlenv);
MNode* ml_vector_size (MNode* cell, MlEnv* mlenv);
MNode* ml_vector_put (MNode* cell, MlEnv* mlenv);
+MNode* ml_vector_del (MNode* cell, MlEnv* mlenv);
MNode* ml_vector_push (MNode* cell, MlEnv* mlenv);
MNode* ml_vector_pop (MNode* cell, MlEnv* mlenv);
MNode* ml_vector_append (MNode* cell, MlEnv* mlenv);
MNode* ml_table (MNode* cell, MlEnv* mlenv);
MNode* ml_table_get (MNode* cell, MlEnv* mlenv);
MNode* ml_table_put (MNode* cell, MlEnv* mlenv);
+MNode* ml_table_del (MNode* cell, MlEnv* mlenv);
MNode* ml_table_append (MNode* cell, MlEnv* mlenv);
MNode* ml_table_to_list (MNode* cell, MlEnv* mlenv);
MNode* ml_table_eval (MNode* cell, MlEnv* mlenv);