MathGroup Archive 2012

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

Search the Archive

Re: opposite of AppendTo

  • To: mathgroup at smc.vnet.net
  • Subject: [mg124365] Re: opposite of AppendTo
  • From: Szabolcs Horvát <szhorvat at gmail.com>
  • Date: Tue, 17 Jan 2012 05:57:13 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <jf13lb$5ma$1@smc.vnet.net>

On 2012.01.16. 14:02, burke wrote:
> AppendTo[s,e] appends "e" to "s" and then RESETS "s". How does one
> delete or remove an element "e" from a list "s" and then RESET "s"?
> The _reset_ is my problem.  I want to be able to add and delete
> elements of a list (a list of graphical elements with very low
> opacity).  I can "appendto" the list at will but am unable to delete
> elements (using Delete, DeleteCases, Except, Select, etc.). Deleting
> "e" from "s" is easy enough, but resetting "s" seems impossible.
> Help!!
>

You can always re-assign the list, as in

   s = Most[s];

In Mathematica functions almost never modify their arguments directly. 
They return a modified copy instead.

Exceptions are Set and AppendTo/PrependTo, which do modify the argument.

-- 
Szabolcs Horvát
Mma QA site proposal: http://area51.stackexchange.com/proposals/37304



  • Prev by Date: Re: opposite of AppendTo
  • Next by Date: Re: How to remove the Null character in a Table?
  • Previous by thread: Re: opposite of AppendTo
  • Next by thread: How to easily set up all coefficients to be positive in Solving an integer equation?