Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2011

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

Search the Archive

Re: list equation

  • To: mathgroup at
  • Subject: [mg121929] Re: list equation
  • From: Richard Hofler <rhofler at>
  • Date: Fri, 7 Oct 2011 04:42:53 -0400 (EDT)
  • Delivered-to:
  • References: <>

Hello Dimitris,

Try this.

In[36]:= Clear[lst]
shortLst = DeleteDuplicates[lst,#1==Reverse[#2]&]

Out[37]= {{1,1},{1,2},{1,3},{1,4},{1,5},{2,1},{2,2},{2,3},{2,4},{2,5},{3,1},{3,2},{3,3},{3,4},{3,5},{4,1},{4,2},{4,3},{4,4},{4,5},{5,1},{5,2},{5,3},{5,4},{5,5}}
Out[38]= 25

Out[39]= {{1,1},{1,2},{1,3},{1,4},{1,5},{2,2},{2,3},{2,4},{2,5},{3,3},{3,4},{3,5},{4,4},{4,5},{5,5}}
Out[40]= 15

Richard Hofler
From: dimitris [dimmechan at]
Sent: Thursday, October 06, 2011 4:24 AM
To: mathgroup at
Subject: [mg121929] list equation

Hello to all.


lst = Tuples[Range[100], 2];

In the previous list appear elements such us {x,y} and {y,x}. (e.g.
{3,4} and {4,3}).
I want to create a new list with {y,x} dropped (that is, in the new
list appears only {3,4}
and not {4,3}).

I use

lstnew = Union[lst, SameTest -> (#1 == Reverse[#2] &)]

However it is needed almost 150 sec for this procedure ($Version->5.2
for Windows)
I know that my laptop is too old but I guess there is a more efficient
way to
create lstnew.

Any ideas?

Thanks a lot


  • Prev by Date: Re: A variable defaulting to a previous variable?
  • Next by Date: Re: average of the consecutive coin tosses
  • Previous by thread: list equation
  • Next by thread: Re: list equation