Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #7951

Re: opposite of AppendTo

From Szabolcs Horvát <szhorvat@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: opposite of AppendTo
Date 2012-01-17 10:57 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jf3k7b$q5t$1@smc.vnet.net> (permalink)
References <jf13lb$5ma$1@smc.vnet.net>

Show all headers | View raw


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

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

opposite of AppendTo burke <burket@mailbox.sc.edu> - 2012-01-16 12:02 +0000
  Re: opposite of AppendTo "Nasser M. Abbasi" <nma@12000.org> - 2012-01-17 08:31 +0000
  Re: opposite of AppendTo "Nasser M. Abbasi" <nma@12000.org> - 2012-01-17 08:41 +0000
  Re: opposite of AppendTo Szabolcs Horvát <szhorvat@gmail.com> - 2012-01-17 10:57 +0000

csiph-web