Re: Find a maxlist of within subsets

• To: mathgroup at smc.vnet.net
• Subject: [mg127883] Re: Find a maxlist of within subsets
• From: Ray Koopman <koopman at sfu.ca>
• Date: Thu, 30 Aug 2012 04:06:46 -0400 (EDT)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• Delivered-to: l-mathgroup@wolfram.com
• Delivered-to: mathgroup-newout@smc.vnet.net
• Delivered-to: mathgroup-newsend@smc.vnet.net
• References: <k1k8fh\$8vh\$1@smc.vnet.net>

```On Aug 28, 10:15 pm, Kate <katesek... at gmail.com> wrote:
> Hi all,
>
> Given a list [a,b,c,d,e,f,g], I am trying to find the maxlist for overlapping subsets of 3 [{abc},{bcd},{cde},{def},{efg}].  To make things more difficult, this list needs to always retain the first and last member of the list [{a},{abc},{bcd},{cde},{def},{efg},{g}].  And, finally, I only want to know if the middle variable of each subset is equal to or greater than the other variables in the subset.
>
> So, for the list [60,67,65,64,69,69,62], which would then be broken into the subsets [{60},{60,67,65},{67,65,64},{65,64,69},{64,69,69},{69,69,62},{62}] I want to return the value: [60, 67, 69, 69, 62].
>
> Any thoughts on the code I could use?

Flatten@{lst[[1]], Cases[Partition[lst,3,1],
{a_,b_,c_} /; b >= Max[a,c] -> b], lst[[-1]]}

{60, 67, 69, 69, 62}

```

• Prev by Date: Re: Find a maxlist of within subsets
• Next by Date: Re: Luke's list of mathematica questions
• Previous by thread: Re: Find a maxlist of within subsets