MathGroup Archive 2011

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

Search the Archive

Re: Nested List Abs[]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg121049] Re: Nested List Abs[]
  • From: Dana DeLouis <dana01 at me.com>
  • Date: Thu, 25 Aug 2011 07:04:46 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com

>  How do I delete from the larger list any integer pair
>  whose numerical distance apart is greater than one?

Here`s just another of many options:

m=RandomInteger[{-2,2},{10,2}]

{{-1,2},{1,-2},{2,2},{1,-1},{-1,-2},{-2,-2},{2,1},{-2,-1},{1,-2},{2,0}}

Select[m,EuclideanDistance@@#<=1 &]

{{2,2},{-1,-2},{-2,-2},{2,1},{-2,-1}}

Note:  These were removed from the list:

Complement[m,%]
{{-1,2},{1,-2},{1,-1},{2,0}}

= = = = = = = = = = =
HTH   :>)
Dana DeLouis
$Version
8.0 for Mac OS X x86 (64-bit) (November 6, 2010)




On Aug 24, 3:18 am, Sam Korn <s... at kornfamily.com> wrote:
> I have a list, and each element of the
> list is a sublist with two integers. How do I delete from the larger
> list any integer pair whose numerical distance apart is greater than
> one? I'd been trying to map Abs[Subtract[#1,#2]]&<1 over the list, but
> so far that hasn't worked.
> 
> Any suggestions?
> 
> Sent from my iPhone






  • Prev by Date: Better use of PolynomialReduce?
  • Next by Date: Re: Nested List Abs[]
  • Previous by thread: Re: Nested List Abs[]
  • Next by thread: Re: Nested List Abs[]