Re: ? Repeated Patterns ?
- To: mathgroup at smc.vnet.net
- Subject: [mg19016] Re: ? Repeated Patterns ?
- From: Bruno Daniel <bruno.daniel at hadiko.de>
- Date: Tue, 3 Aug 1999 13:44:50 -0400
- Organization: University of Karlsruhe
- References: <7n8nfc$k9m@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi DongGook Beware that ".." doesn't match the same expression, but the same pattern, for example: In[1]:={0,1,2,3} /. {x_Integer..}->{x} Out[1]= {0,1,2,3} Another problem in your approach is that all patterns except for the last try to find the shortest match: If you want to collaps general repetitions of arguments you can do it this way (the pattern is applied repeatedly): In[2]:={0,3,5,0,0,1,3,3,4} //.{a___,x_Integer,b___,x_,c___}->{a,x,b,c} Out[2]={0,3,5,1,4} If you rather want to collapse subsequent repetitions: In[3]:={0,3,5,0,0,1,3,3,4} //.{a___,x_Integer,x_,c___}->{a,x,c} Out[3]={0,3,5,0,1,3,4} Yours sincerely Bruno