MathGroup Archive 1999

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

Search the Archive

Re: dummy index list

  • To: mathgroup at
  • Subject: [mg20275] Re: [mg20256] dummy index list
  • From: "Andrzej Kozlowski" <andrzej at>
  • Date: Mon, 11 Oct 1999 02:19:51 -0400
  • Sender: owner-wri-mathgroup at

I shall only attempt to answer question 1. First, the code you sent is 
incorrect. I assume that you meant:
testlist = {a, -b, c, -d};

Cases[Flatten[testlist, Infinity, Times], _Symbol]
{a, b, c, d}

You can get the same result somewhat quicker with:

DeleteCases[testlist, -1, Infinity]
{a, b, c, d}

This code works because of the OneIdentity attribute of Times, which means
that Times[a] is just a. Moreover, this code has a certain advantage over
yours (probably irrelevant for your needs) in that it will also work in
cases like

testlist = {a^2, -b^2, c, -d};

here your code gives

Cases[Flatten[testlist, Infinity, Times], _Symbol]
{c, d}


DeleteCases[testlist, -1, Infinity]
  2   2
{a , b , c, d}

Andrzej Kozlowski
Toyama International University

>From: "Arturas Acus" <acus at>
To: mathgroup at
>To: mathgroup at
>Subject: [mg20275] [mg20256] dummy index list
>Date: Sun, 10 Oct 1999 00:04:08 -0400

> Dear Group,
> I have 2 questions:
> 1) I want the fastest way to select dummy symbols
> from some expression. Suppose we have a list of
> dummy indices {a,-b,c, -d}. What is the fastest way to
> get rid of the minus sign?
> Here is my solution:
> testlist={a,-b,c, -d};
> Map[Cases[Flatten[#,Infinity,Times],_Symbol]&,testlist]
> However I am not satisfied and believe there should
> be a simple solution for such a simple task. I will use
> this function very often in future, so it should be
> as fast as possible.
> 2) I am not a professional programmer, so I am
> very interesting in algorithm speed estimates
> (there was a lot of such estimates published
> recently in this group).
> Do some tutorials on the web exist on this subject?
> At the moment I am interesting in Mathematica SameQ
> algorithm asymptotic (theoretic).
> Is it n or log(n) or some other?
> How one can know or guess this? Probably
> there are some tables for various basic operations,
> for example, like
> 1.the best selection algorithm can be done at speed ??
> 2. the list intersection algorithm is ??
> 3 the union can be done at ??
> and so on. Thanks.
> Dr. Arturas Acus
> Institute of Theoretical
> Physics and Astronomy
> Gostauto 12, 2600,Vilnius
> Lithuania
> E-mail: acus at
>    Fax: 370-2-225361
>    Tel: 370-2-612906

  • Prev by Date: Re: vector pattern?
  • Next by Date: Tough Integral
  • Previous by thread: dummy index list
  • Next by thread: Finding roots of complex eqs.