MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: is there really no efficient way to delete an element from a list??


Use linked lists, as in

queue={1,{2,{3,{4}}}}
queue = Rest[queue]

Dave Withoff
Wolfram Research

> hi, i tried to implement a queue with mathematica;
> is it possible that there is no O(1) way to get
> queue = Rest[queue]  ??
> 
> it seems that mathematica uses call by value instead of call by reference
> here;
> i know that there are PrependTo[] and ApendTo[] for building the list; is
> there any equivalent to these functions to remove elements?
> 
> or is there another way to implement a stack or queue with constant time
> access?
> 
> --martin.
> 
> ----------------------------------------------------------------------------
> Martin Bauer                          email:  martin.bauer at in.tum.de
> Department of Computer Science          www:  http://www.in.tum.de/~bauerma
> Technische Universitat Munchen          tel:  +49-89-289-25724
> D-80290 Munchen, Germany               room:  3202  main bldg, Arcisstr.21
> ----------------------------------------------------------------------------


  • Prev by Date: Re: Newbie question: pairswise function application
  • Next by Date: AW: Re: Integrate returns 0
  • Previous by thread: Re: is there really no efficient way to delete an element from a list??
  • Next by thread: Re: is there really no efficient way to delete an element from a list??