Esempio n. 1
0
void test6(void) {
  ElementNode_handle pE1=0,pE2=0,pE3=0;
  int i;
  printf("\n==== SCALAR MULTIPLICATION =================\n");
  for(i=0;i<20;++i) insert_element(&pE1,i,i*i);
  printf("vector pE1 formatted:\n");
  printf_elements(pE1,"%4d",20); printf("\n");

  for(i=0;i<20;++i) insert_element(&pE2,40-2*i,i);
  printf("vector pE2 formatted:\n");
  printf_elements(pE2,"%4d",40); printf("\n");
 
  for(i=0;i<20;++i) {
    if (i%2) insert_element(&pE3,2*i,i);
    else     insert_element(&pE3,41-2*i,-i);
  }
  printf("vector pE3 formatted:\n");
  printf_elements(pE3,"%4d",40); printf("\n");
  printf("scalar product pE1 and pE2 = %i\n",scalar_product(pE1,pE2));
  printf("scalar product pE2 and pE3 = %i\n",scalar_product(pE2,pE3));
  printf("scalar product pE3 and pE1 = %i\n",scalar_product(pE3,pE1));
  printf("scalar product pE1 and pE1 = %i\n",scalar_product(pE1,pE1));

  free_elements(pE1);
  free_elements(pE2);
  free_elements(pE3);
}
Esempio n. 2
0
void test9(void) {
  ElementNode_handle pE1=0,pE2=0,pRes;
  int i;
  printf("\n==== VECTOR ADDITION 2 =================\n");
  for(i=0;i<5;++i) insert_element(&pE1,2000*i,i);

  for(i=0;i<10;++i) insert_element(&pE2,1000*i,i);
 

  pRes=add(pE1,pE2);
  printf("pE1 + pE2 = \n"); 
  printf("raw:\n"); print_elements(pRes); printf("\n");
  free_elements(pRes);

  pRes=add(pE2,pE1);
  printf("pE2 + pE1 = \n"); 
  printf("raw:\n"); print_elements(pRes); printf("\n"); 
  free_elements(pRes);

  pRes=add(pE1,pE1);
  printf("pE1 + pE1 = \n");
   printf("raw:\n"); print_elements(pRes); printf("\n"); 
  free_elements(pRes);

  free_elements(pE1);
  free_elements(pE2);
}
void test10( void )
{
    ElementNode * pE1=0, *pE2=0, *pRes;
    int i;
    printf( "\n==== VECTOR ADDITION (ZEROES) ========\n" );
    for( i=0; i<20; ++i ) insert_element( &pE1,i,i*i );
    printf( "vector pE1 formatted:\n" );
    printf_elements( pE1,"%4d",20 );
    printf( "\n" );
    for( i=0; i<20; ++i ) insert_element( &pE2,i,-i*i );
    printf( "vector pE2 formatted:\n" );
    printf_elements( pE2,"%4d",20 );
    printf( "\n" );
    pRes=add( pE1,pE2 );
    printf( "pE1 + pE2 = \n" );
    printf_elements( pRes,"%4d",20 );
    printf( "\n" );
    printf( "raw:\n" );
    print_elements( pRes );
    printf( "\n" );
    free_elements( pRes );
    pRes=add( pE2,pE1 );
    printf( "pE2 + pE1 = \n" );
    printf_elements( pRes,"%4d",20 );
    printf( "\n" );
    printf( "raw:\n" );
    print_elements( pRes );
    printf( "\n" );
    free_elements( pRes );
    free_elements( pE1 );
    free_elements( pE2 );
}
Esempio n. 4
0
void test15(void) {
  ElementNode_handle pE1=0,pE2=0,pE3=0;
  RowNode_handle pR=0; 
  int i;
  printf("\n====== INSERT ROWS MIDDLE =========================\n");
  for(i=0;i<5;++i) insert_element(&pE1,2*i,10*i-50);
  printf_elements(pE1,"%4d",10); printf("\n");

  for(i=0;i<20;++i) insert_element(&pE2,20-i,i);
  printf_elements(pE2,"%4d",10); printf("\n");
 
  for(i=0;i<10;++i) {
    if (i%2) insert_element(&pE3,i,i);
    else     insert_element(&pE3,10-i,-i);
  }
  
  insert_row(&pR,8,pE3);
  printf("after insert:\n"); printf_rows(pR,"%4i",10); printf("\n");
  insert_row(&pR,0,pE1);
  printf("after insert:\n"); printf_rows(pR,"%4i",10); printf("\n");
  insert_row(&pR,5,pE2);
  printf("after insert:\n"); printf_rows(pR,"%4i",10); printf("\n");

  free_rows(pR);
}
Esempio n. 5
0
int main(int argc, char* argv[])
{
printf("Let us formulate the problem statement to understand the deletion process. Given a key, delete the first occurrence of this key in linked list.\nTo delete a node from linked list, we need to do following steps.\n1) Find previous node of the node to be deleted.\n2) Changed next of previous node.\n3) Free memory for the node to be deleted.\nSince every node of linked list is dynamically allocated using malloc() in C, we need to call free() for freeing memory allocated for the node to be deleted.\n");
//struct node *head = NULL;
//head = (struct node*)malloc(sizeof(_node));
    _node *head = NULL;
    insert_element(&head,1);
    insert_element(&head,2); 
    display_list(head);
   // printf(" number of nodes = %d");
    insert_element(&head,7);
    insert_element(&head,8);
    insert_element(&head,9);
    insert_element(&head,12);
    insert_element(&head,111);
    display_list(head);
    //delete_node(&head,111);
    display_list(head);
    insert_element(&head,13);
    insert_element(&head,15);
    //head->next->next->next->next->next->next = head->next->next;
    int give_answer = detect_loop(head);
    //delete_node(&head,1);
    //display_list(head);
    //delete_node(&head,12);
    //display_list(head);
    //delete_node(&head,8);
    //display_list(head);
return 0;
}
void test7( void )
{
    ElementNode * pE1=0, *pE2=0;
    int i;
    printf( "\n==== SCALAR MULTIPLICATION 2 =================\n" );
    for( i=0; i<20; ++i ) insert_element( &pE1,1000*i,i*i );
    for( i=0; i<20; ++i ) insert_element( &pE2,500*i,i );
    printf( "scalar product pE1 and pE2 = %i\n",scalar_product( pE1,pE2 ) );
    printf( "scalar product pE2 and pE1 = %i\n",scalar_product( pE2,pE1 ) );
    printf( "scalar product pE1 and pE1 = %i\n",scalar_product( pE1,pE1 ) );
    free_elements( pE1 );
    free_elements( pE2 );
}
Esempio n. 7
0
/* functional segment tree */
int insert_element(int prev, int head, int tail, int p)
{
	int now = ++used;
	node[now] = node[prev];
	++node[now].val;
	if(head == tail) return now;

	int m = (head + tail) >> 1;
	if(p <= m) node[now].son[0] = insert_element(node[prev].son[0], head, m, p);
	else node[now].son[1] = insert_element(node[prev].son[1], m + 1, tail, p);

	node[now].val = node[node[now].son[0]].val + node[node[now].son[1]].val;
	return now;
}
Esempio n. 8
0
static void inc_id_count(int id, id_le **list)
{
    id_le *ptr;
    ptr = *list;

    if(ptr == NULL)
        insert_element(id, list);
    else
    {
        while(ptr->next != NULL && ptr->id != id) ptr = ptr->next;
        if(ptr->id == id)
            ptr->count++;
        else
            insert_element(id, list);
    }
}
Esempio n. 9
0
/* joins  l2 onto l1 */
static int list_join_internal (SLang_List_Type *l1, SLang_List_Type *l2)
{
   Chunk_Type *chunk;
   SLindex_Type num2;

   chunk = l2->first;
   num2 = l2->length;
   while (num2 > 0)
     {
	SLindex_Type i, imax;
	SLang_Object_Type *objs;
	objs = chunk->elements;
	i = 0; imax = chunk->num_elements;

	while ((num2 > 0) && (i < imax))
	  {
	     SLang_Object_Type obj;
	     if (-1 == _pSLslang_copy_obj (objs+i, &obj))
	       return -1;

	     if (-1 == insert_element(l1, &obj,  l1->length))
	       {
		  SLang_free_object (&obj);
		  return -1;
	       }
	     i++;
	     num2--;
	  }
	chunk = chunk->next;
     }
   return 0;
}
void check_funcdefinition(node *root){
    node *aux = root->son;
    node *scnd_aux = NULL, *param_aux = NULL;
    char *type = NULL;
    char *f_name = NULL;
    int num_params = 0;
    int n_pointers = 0;
    int i;

    check_funcdeclaration(root);
    type = (char*)calloc(strlen(aux->str_type)+1,sizeof(char));
    strcpy(type,tolower_str(aux->str_type));

    for(aux = aux->brother; strcmp(aux->str_type,"Pointer")==0; aux=aux->brother){
      type = (char*)realloc(type,2);
      strcat(type,"*");
    }

    f_name = (char*)calloc(strlen(aux->value)+1,sizeof(char));
    strcpy(f_name,aux->value);

    insert_table(f_name,type);

    aux = aux->brother;
    /*if(equal_params(aux,f_name)==0){
      remove_table(f_name);
      return;
    }*/

    num_params = aux->n_sons;

    for(i=0,scnd_aux = aux->son; i<num_params; i++,scnd_aux=scnd_aux->brother){

      n_pointers = 0;
      param_aux = scnd_aux->son;

      type = (char*)calloc(strlen(param_aux->str_type)+1,sizeof(char));
      strcpy(type,tolower_str(param_aux->str_type));

      param_aux = param_aux->brother;


      if(param_aux!=NULL){
        for(; param_aux!=NULL && strcmp(param_aux->str_type,"Pointer") == 0; param_aux=param_aux->brother){
          n_pointers++;
        }

        if(param_aux != NULL){
          insert_element(f_name,type,n_pointers,param_aux->value,NULL,0,NULL,1,0);
        }
      }


    }


    aux = aux->brother;
    check_funcbody(aux,f_name);

}
Esempio n. 11
0
int main()
{
	int n, m, k, type;
	std::scanf("%d %d %d %d", &n, &m, &k, &type);
	for(int i = 0; i <= n; ++i)
		val[i] = min_v[i] = ~0u >> 1;
	for(int i = 1; i <= m; ++i)
	{
		int u, v;
		std::scanf("%d %d", &u, &v);
		if(u == v) 
		{
			ntr[i] = i;
			continue;
		}
		min_v[i + n] = val[i + n] = i;
		from[i] = u, point[i] = v;

		int mu = find(u), mv = find(v);
		if(mu != mv)
		{
			mfa[mu] = mv;
			ntr[i] = 0;
		} else {
			make_root(u);
			access(v);
			splay(v);

			int node = min_v[v];
			cut(n + node, from[node]);
			cut(n + node, point[node]);
			ntr[i] = node;
		}

		link(u, i + n);
		link(v, i + n);
	}

	for(int i = 1; i <= m; ++i)
		root[i] = insert_element(root[i - 1], 0, m, ntr[i]);

	int lastans = 0;
	for(int i = 0; i != k; ++i)
	{
		int l, r;
		std::scanf("%d %d", &l, &r);
		if(type) 
		{
			l ^= lastans;
			r ^= lastans;
		}

		if(l == 1 && r == m)
			lastans = 1;
		else lastans = n - ask(root[l - 1], root[r], 0, m, l - 1);
		std::printf("%d\n", lastans);
	}

	return 0;
}
Esempio n. 12
0
static int pop_as_list_internal (unsigned int count)
{
   SLang_List_Type *list;

   if (NULL == (list = allocate_list (count)))
     return -1;

   while (count)
     {
	SLang_Object_Type obj;

	if (-1 == SLang_pop (&obj))
	  goto return_error;

	if (-1 == insert_element (list, &obj, 0))
	  {
	     SLang_free_object (&obj);
	     goto return_error;
	  }

	count--;
     }
   return push_list (list, 1);

return_error:
   free_list (list);
   return -1;
}
Esempio n. 13
0
static VALUE rb_bst_insert_value(VALUE self,VALUE key,VALUE data) {
  bst_head *headNode;
  Data_Get_Struct(self,bst_head,headNode);
  insert_element(&(headNode->head),create_element(key,data));
  headNode->size++;
  return self;
}
Esempio n. 14
0
void test2(void) {
  ElementNode_handle pE3=0;
  int i;
  printf("\n====== INSERTS MIDDLE =============================\n");
 
  for(i=0;i<20;++i) {
    if (i%2) insert_element(&pE3,i,i);
    else     insert_element(&pE3,20-i,-i);
  }
  printf("vector 3 formatted:\n");
  printf_elements(pE3,"%4d",20); printf("\n");
  printf("vector 3 raw:\n");
  print_elements(pE3); printf("\n");

  free_elements(pE3);
}
Esempio n. 15
0
int main()
{
  int option;
  printf("\n");
  printf(">>> c program to implement queue operations <<<");
  do
  {
   printf("\n\n 1.Insert an element");
   printf("\n 2.Delete an element");
   printf("\n 3.Display queue");
   printf("\n 4.Exit");
   printf("\n Enter your choice: ");
   scanf("%d",&option);
   switch(option)
   {
     case 1: insert_element();
              break;
     case 2: delete_element();
             break;
     case 3: display_queue();
             break;
     case 4: return 0;
   }
 
  }while(option!=4);
}
Esempio n. 16
0
File: group.c Progetto: BIC-MNI/minc
/* ----------------------------- MNI Header -----------------------------------
@NAME       : acr_group_insert_element
@INPUT      : group
              element
@OUTPUT     : (none)
@RETURNS    : Acr_Status
@DESCRIPTION: Insert an element into a group. If an element of the same 
              id already exists in the list, it is removed and deleted.
@METHOD     : 
@GLOBALS    : 
@CALLS      : 
@CREATED    : June 17, 1997 (Peter Neelin)
@MODIFIED   : 
---------------------------------------------------------------------------- */
Acr_Status acr_group_insert_element(Acr_Group group,
                                    Acr_Element element)
{
   Acr_Element next_element, prev_element, cur_element;
   int element_id;

   /* Check that the element belongs in this group */
   if (group->group_id != acr_get_element_group(element)) {
      (void) fprintf(stderr, 
          "ACR error: Cannot add element %d (group %d) to group %d\n",
                     acr_get_element_element(element),
                     acr_get_element_group(element),
                     group->group_id);
      exit(EXIT_FAILURE);
   }

   /* Get element id */
   element_id = acr_get_element_element(element);

   /* Check that new element has id > group length element id */
   if (element_id < ACR_EID_GRPLEN) {
      (void) fprintf(stderr, 
      "ACR error: Cannot add element id %d <= length id (%d) to group %d\n",
                     element_id, ACR_EID_GRPLEN, group->group_id);
      exit(EXIT_FAILURE);
   }

   /* Check whether the the element should be added after the last element */
   if (acr_get_element_element(group->list_tail) < element_id) {
      prev_element = group->list_tail;
      next_element = NULL;
   }

   /* Otherwise, search for the appropriate location */
   else {
      prev_element = NULL;
      next_element = group->list_head;
      while ((next_element != NULL) && 
             (acr_get_element_element(next_element) < element_id)) {
         prev_element = next_element;
         next_element = acr_get_element_next(next_element);
      }
   }

   /* Check for an existing element and get rid of it */
   if ((next_element != NULL) &&
       (acr_get_element_element(next_element) == element_id)) {

      /* Set pointers and get rid of the old element */
      cur_element = next_element;
      next_element = acr_get_element_next(cur_element);
      remove_element(group, cur_element, prev_element);

   }

   /* Insert the new element */
   return insert_element(group, element, prev_element);

}
Esempio n. 17
0
void test11(void) {
  ElementNode_handle pE1=0;
  int i;
  printf("\n==== TESTING FIND ========\n");
  for(i=0;i<20;i+=2) insert_element(&pE1,i,i*i);
  printf_elements(pE1,"%4d",20); printf("\n");
  printf("print vector using get - very inefficient!!!\n");
  for(i=0;i<20;++i) printf("index %i, value %i\n",i,get(pE1,i));
  free_elements(pE1);
}
Esempio n. 18
0
void test12(void) {
  ElementNode_handle pE1=0;
  int pos=10000;
  printf("\n==== TESTING FIND 2 ========\n");
  insert_element(&pE1,pos,5);
  print_elements(pE1); printf("\n");

  printf ("value %i at position %i\n",get(pE1,pos),pos);
  free_elements(pE1);
}
Esempio n. 19
0
/* Inserts STRING in SA just before the string with index BEFORE, which must be
   less than or equal to the number of strings in SA.  Ownership of STRING
   transfers to SA.

   In general, this function runs in O(n) time in the number of strings that
   must be shifted to higher indexes; if BEFORE is the number of strings in SA,
   it runs in amortized constant time. */
void
string_array_insert_nocopy (struct string_array *sa, char *string,
                            size_t before)
{
  string_array_expand__ (sa);
  if (before < sa->n)
    insert_element (sa->strings, sa->n, sizeof *sa->strings, before);

  sa->strings[before] = string;
  sa->n++;
}
Esempio n. 20
0
void test0(void) {
  ElementNode_handle pE1=0;
  int i;
  printf("\n====== INSERTS BACK =============================\n");
  for(i=0;i<20;++i) insert_element(&pE1,3*i,i*i);
  printf("vector 1 formatted:\n");
  printf_elements(pE1,"%4d",80); printf("\n");
  printf("vector 1 raw:\n");
  print_elements(pE1); printf("\n");

  free_elements(pE1);
}
Esempio n. 21
0
	void RStarTreeNode::adjust_tree(RStarTreePtr tree,
		RStarTreeNodePtr node, RStarTreeNodePtrStack &path_buffer, _32BitSet &oft)
	{
		bool adjust;

		adjust = insert_element(tree, node, path_buffer, oft);

		if (!adjust)
		{
			adjust_tree(path_buffer);
		}
	}
void test8( void )
{
    ElementNode * pE1=0, *pE2=0, *pE3=0, *pRes;
  int i;
  printf("\n==== VECTOR ADDITION =================\n");
  for(i=0;i<20;++i) insert_element(&pE1,i,i*i);
  printf("vector pE1 formatted:\n");
  printf_elements(pE1,"%4d",20); printf("\n");

  for(i=0;i<10;++i) insert_element(&pE2,20-2*i,i);
  printf("vector pE2 formatted:\n");
  printf_elements(pE2,"%4d",20); printf("\n");
 
  for(i=0;i<5;++i) {
    if (i%2) insert_element(&pE3,4*i,i);
    else     insert_element(&pE3,21-4*i,-i);
  }
  printf("vector pE3 formatted:\n");
  printf_elements(pE3,"%4d",20); printf("\n");

  pRes=add(pE1,pE2);
  printf("pE1 + pE2 = \n"); printf_elements(pRes,"%4d",20); printf("\n");
  /* printf("raw:\n"); print_elements(pRes); printf("\n"); */
  free_elements(pRes);
  pRes=add(pE2,pE3);
  printf("pE2 + pE3 = \n"); printf_elements(pRes,"%4d",20); printf("\n");
  /* printf("raw:\n"); print_elements(pRes); printf("\n"); */
  free_elements(pRes);
  pRes=add(pE3,pE1);
  printf("pE3 + pE1 = \n"); printf_elements(pRes,"%4d",20); printf("\n");
  /* printf("raw:\n"); print_elements(pRes); printf("\n"); */
  free_elements(pRes);
  pRes=add(pE1,pE3);
  printf("pE1 + pE3 = \n"); printf_elements(pRes,"%4d",20); printf("\n");
  /* printf("raw:\n"); print_elements(pRes); printf("\n"); */
  free_elements(pRes);
  free_elements(pE1);
  free_elements(pE2);
  free_elements(pE3);
}
void check_declaration(node *root, char *table_name,int srch_global){

    char *type = NULL;
    node *aux = root->son;
    int n_pointers = 0;

    /*store declaration type*/
    type = (char*)calloc(strlen(aux->str_type)+1,sizeof(char));
    strcpy(type,aux->str_type);
    aux = aux->brother; /*type is stored, so let's go to the ast or Id*/

    /*count number of pointers*/
    for(;strcmp(aux->str_type,"Pointer") == 0; aux=aux->brother){
      n_pointers++;
    }

    if(strcmp(root->str_type,"ArrayDeclaration") == 0)
      insert_element(table_name,type,n_pointers,aux->value,aux->brother->value,0,NULL,0,srch_global);
    else/*declaration*/
      insert_element(table_name,type,n_pointers,aux->value,NULL,0,NULL,0,srch_global);

}
void sort_y(std::vector<Line_Segment> line){
    std::vector<BothPoint> both_p;
    for(int i = 0; i < line.size(); i++){
        BothPoint tmp1 = {line[i].get_first_point(),line[i].get_end_point()};
        BothPoint tmp2 = {line[i].get_end_point(),line[i].get_first_point()};
        both_p.push_back(tmp1);
        both_p.push_back(tmp2);
    }
    QuickSort(both_p, 0, (int)both_p.size()-1);
    
    for(int i = 0; i < both_p.size(); i++)
        insert_element(both_p[i].first_point, both_p[i].end_point);
}
Esempio n. 25
0
void test1(void) {
  ElementNode_handle pE2=0;
  int i;
  printf("\n====== INSERTS BACK =============================\n");

  for(i=0;i<20;++i) insert_element(&pE2,20-i,i);
  printf("vector 2 formatted:\n");
  printf_elements(pE2,"%4d",20); printf("\n");
  printf("vector 2 raw:\n");
  print_elements(pE2); printf("\n");
 
  free_elements(pE2);
}
Esempio n. 26
0
File: group.c Progetto: BIC-MNI/minc
/* ----------------------------- MNI Header -----------------------------------
@NAME       : acr_group_add_element
@INPUT      : group
              element
@OUTPUT     : (none)
@RETURNS    : Acr_Status
@DESCRIPTION: Add an element to an acr-nema group
@METHOD     : 
@GLOBALS    : 
@CALLS      : 
@CREATED    : November 10, 1993 (Peter Neelin)
@MODIFIED   : 
---------------------------------------------------------------------------- */
Acr_Status acr_group_add_element(Acr_Group group, Acr_Element element)
{
   /* Check that the element belongs in this group */
   if (group->group_id != acr_get_element_group(element)) {
      (void) fprintf(stderr, 
          "ACR error: Cannot add element %d (group %d) to group %d\n",
                     acr_get_element_element(element),
                     acr_get_element_group(element),
                     group->group_id);
      exit(EXIT_FAILURE);
   }

   /* Insert the element at the tail */
   return insert_element(group, element, group->list_tail);
}
Esempio n. 27
0
int SLang_list_insert (SLang_List_Type *list, int indx)
{
   SLang_Object_Type obj;

   if (-1 == SLang_pop (&obj))
     return -1;

   if (indx < 0)
     indx += list->length;

   if (-1 == insert_element (list, &obj, indx))
     {
	SLang_free_object (&obj);
	return -1;
     }
   return 0;
}
Esempio n. 28
0
main() {
  struct node *T = NULL;;
  int i = 0, n = 0, val = 0;

  printf("Number of values: ");
  scanf("%d", &n);
  
  for(i = 0; i < n; i++) {
    scanf("%d", &val);
    T = insert_element(T, val);
  }
  print_list(T);
  T = reverse_list(T);
  print_list(T);
  T = reverse_list_recursive(T);
  print_list(T);
}
void check_funcdeclaration(node *root){

    char *type = NULL;
    node *aux = root->son;
    node *scnd_aux = NULL;
    int n_pointers = 0;
    char *f_name = NULL;
    char **f_params = NULL;
    int n_params = 0;
    int i;

    if(root == NULL)
      return;

    type = (char*)calloc(strlen(aux->str_type)+1,sizeof(char));
    strcpy(type,aux->str_type);

    for(aux = aux->brother; strcmp(aux->str_type,"Pointer") == 0; aux=aux->brother){
      n_pointers++;
    }

    f_name = aux->value;
    aux = aux->brother;

    for(scnd_aux = aux->son; scnd_aux!=NULL; scnd_aux=scnd_aux->brother){
      n_params++;
    }

    aux->n_sons = n_params;

    f_params = (char**)calloc(n_params,sizeof(char*));
    for(aux=aux->son, i=0; i<n_params; aux=aux->brother,i++){

      f_params[i] = (char*)calloc(strlen(aux->son->str_type)+101,sizeof(char));
      strcpy(f_params[i],tolower_str(aux->son->str_type));
      if(aux->son->brother != NULL){
        for(scnd_aux=aux->son->brother; scnd_aux!=NULL && strcmp(scnd_aux->str_type,"Pointer")==0; scnd_aux=scnd_aux->brother){
          strcat(f_params[i],"*");
        }
      }
    }

    insert_element("Global",type,n_pointers,f_name,NULL,n_params,f_params,0,1);

}
Esempio n. 30
0
static void list_append_elem (void)
{
   int indx;
   SLang_Object_Type obj;
   SLang_List_Type *list;

   indx = -1;
   if (-1 == pop_insert_append_args (&list, &obj, &indx))
     return;

   if (indx < 0)
     indx += list->length;

   if (-1 == insert_element (list, &obj, indx+1))
     SLang_free_object (&obj);

   free_list (list);
}