Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #11551
| From | Bob Hanlon <hanlonr357@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Find a maxlist of within subsets |
| Date | 2012-08-30 08:08 +0000 |
| Message-ID | <k1n72i$e67$1@smc.vnet.net> (permalink) |
| References | <20120829051345.3228C6863@smc.vnet.net> |
| Organization | Time-Warner Telecom |
data = {60, 67, 65, 64, 69, 69, 62};
{data[[1]], Cases[Partition[data, 3, 1],
x_ /; (x[[2]] >= x[[1]] && x[[2]] >= x[[3]]) :>
x[[2]]], data[[-1]]} // Flatten
{60, 67, 69, 69, 62}
Bob Hanlon
On Wed, Aug 29, 2012 at 1:13 AM, Kate <katesekula@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?
>
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: Find a maxlist of within subsets Bob Hanlon <hanlonr357@gmail.com> - 2012-08-30 08:08 +0000
csiph-web