Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #4552
| From | Ray Koopman <koopman@sfu.ca> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Nested List Abs[] |
| Date | 2011-08-24 11:53 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <j32onl$dtu$1@smc.vnet.net> (permalink) |
| References | <j328jc$b4n$1@smc.vnet.net> |
On Aug 24, 12: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
Here are five ways to do it. There are many more.
Cases[data, {x_,y_} /; Abs[x-y] < 2 ]
Select[data, Abs[Subtract @@ # ] < 2 &]
Pick[data, Subtract @@ Transpose @ data, -1|0|1 ]
Pick[data, Thread[ Abs[ Subtract @@ Transpose @ data] < 2 ] ]
Pick[data, UnitStep[ Abs[ Subtract @@ Transpose @ data ] - 2 ], 0 ]
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Nested List Abs[] Sam Korn <sam@kornfamily.com> - 2011-08-24 07:18 +0000 Re: Nested List Abs[] Ray Koopman <koopman@sfu.ca> - 2011-08-24 11:53 +0000 Re: Nested List Abs[] "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2011-08-25 11:06 +0000
csiph-web