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


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

Re: Nested List Abs[]

Started bySam Korn <sam@kornfamily.com>
First post2011-08-25 11:10 +0000
Last post2011-08-25 11:10 +0000
Articles 1 — 1 participant

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

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Nested List Abs[] Sam Korn <sam@kornfamily.com> - 2011-08-25 11:10 +0000

#4563 — Re: Nested List Abs[]

FromSam Korn <sam@kornfamily.com>
Date2011-08-25 11:10 +0000
SubjectRe: Nested List Abs[]
Message-ID<j35aj6$ofb$1@smc.vnet.net>
Thanks guys! Sorry that was such an obvious question, but I'm kinda
new to mathematica!

-Sam

Sent from my iPhone

On Aug 24, 2011, at 7:43 AM, Heike Gramberg <heike.gramberg@gmail.com>
wrote:

> There are multiple ways to do this. Suppose list is your list of
> integer
> pairs, e.g.
>
> list = RandomInteger[{0, 5}, {20, 2}]
>
> then all of the expressions below should give you the set of integer
> pairs with distance <=1:
>
> Select[list, (Abs[#[[1]] - #[[2]]] <= 1 &)]
>
> Cases[list, {a_, b_} /; Abs[a - b] <= 1]
>
> Pick[list, Abs[#1 - #2] & @@@ list, a_ /; a <= 1]
>
> DeleteCases[list, {a_, b_} /; Abs[a - b] > 1]
>
>
> Heike
>
>
> On 24 Aug 2011, at 09:14, Sam Korn 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