Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: A question about pattern

  • To: mathgroup at smc.vnet.net
  • Subject: [mg53849] Re: [mg53815] A question about pattern
  • From: yehuda ben-shimol <benshimo at bgu.ac.il>
  • Date: Sat, 29 Jan 2005 06:03:04 -0500 (EST)
  • References: <200501280744.CAA00380@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

You need to use condition (/;)
myList=Range[10];
ReplaceList[myList, ({a___, b_, c_, d___} /; c > b) -> {a, 2 b, 3 c, d}]
will return
{{2, 6, 3, 4, 5, 6, 7, 8, 9, 10},
{1, 4, 9, 4, 5, 6, 7, 8, 9, 10},
{1, 2, 6, 12, 5, 6, 7, 8, 9, 10},
{1, 2, 3, 8, 15, 6, 7, 8, 9, 10},
{1, 2, 3, 4, 10, 18, 7, 8, 9, 10},
{1, 2, 3, 4, 5, 12, 21, 8, 9, 10},
{1, 2, 3, 4, 5, 6, 14, 24, 9, 10},
{1, 2, 3, 4, 5, 6, 7, 16, 27, 10},
{1, 2, 3, 4, 5, 6, 7, 8, 18, 30}}

yehuda


Daohua Song wrote:

>Dear Group,
>      I am just struggling by the following question: I want to build a 
>rule like this,
>      List/.{a___,b_,c_?(#>b&),d___}->{a,2 b,3 c,d}
>      But it doesn't work.
>
>      please help me! Thanks
>DHSONG
>
>  
>


  • Prev by Date: Re: Nonlinear Curve Fitting
  • Next by Date: Re: Nonlinear Curve Fitting
  • Previous by thread: Re: A question about pattern
  • Next by thread: Re: Re: A question about pattern