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


Groups > comp.soft-sys.math.mathematica > #4556 > unrolled thread

Re: Nested List Abs[]

Started byDana DeLouis <dana01@me.com>
First post2011-08-25 11:06 +0000
Last post2011-08-25 11:06 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Re: Nested List Abs[] Dana DeLouis <dana01@me.com> - 2011-08-25 11:06 +0000

#4556 — Re: Nested List Abs[]

FromDana DeLouis <dana01@me.com>
Date2011-08-25 11:06 +0000
SubjectRe: Nested List Abs[]
Message-ID<j35ace$oct$1@smc.vnet.net>
>  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...@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


[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web