patterns

• To: mathgroup at smc.vnet.net
• Subject: [mg31124] patterns
• Date: Fri, 12 Oct 2001 03:36:41 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```Hi,

I have built the following function for selecting consecutive elements
of a list that do satisfy a particular condition. Here it is:

f[x_, matrix_] := Module[{t, selector},
(* Flatten and group number in pairs *)
t = Partition[Flatten[matrix], 2];
(* Selector : returns true if all in list  > x *)
selector[xx_, list_] := Apply[And, Map[(# > xx) &, list]];
(* select *)
Select[t, selector[x, #] &]]

t = Table[Table[Random[], {4}], {12}];

f[0.01,t]

{{0.301739,0.837578},{0.710472,0.373638},{0.950287,0.828919},{0.327263,
0.861149},{0.734775,0.491342},{0.623224,0.365866},{0.962033,
0.549466},{0.0602337,0.0313664},{0.293098,0.277972},{0.0841844,
0.550993},{0.0538037,0.157458},{0.990937,0.167571},{0.752064,
0.31988},{0.280465,0.793933},{0.801777,0.490962},{0.953202,
0.932784},{0.0670017,0.99962},{0.329978,0.566918},{0.104969,
0.450153},{0.269745,0.535552},{0.811871,0.172181},{0.18556,
0.984558},{0.758067,0.0147228},{0.194623,0.816987}}

seems to work. My question is how one could modify the function so :
1) we pick the first set of consecutive numbers that satisfy the
condition and 2) from any partition of 10 you check the first 5 who
satisfy the condition (again continuous) and then go  to the next row
of the initial matrix.

Do you know any good reference with lots of examples for conditions and
patterns with lists and matrices?

Thank you very much in advance.

yannis

This message contains confidential information and is intended only
for the individual named.  If you are not the named addressee you
should not disseminate, distribute or copy this e-mail.  Please
notify the sender immediately by e-mail if you have received this
e-mail by mistake and delete this e-mail from your system.

E-mail transmission cannot be guaranteed to be secure or error-free
as information could be intercepted, corrupted, lost, destroyed,
arrive late or incomplete, or contain viruses.  The sender therefore
does not accept liability for any errors or omissions in the contents
of this message which arise as a result of e-mail transmission.  If
verification is required please request a hard-copy version.  This
message is provided for informational purposes and should not be
construed as a solicitation or offer to buy or sell any securities or
related financial instruments.

```

• Follow-Ups:
• Prev by Date: Re: Can Fit give function coefficients?
• Next by Date: RE: Newbie Plot-Fit Questions.