MathGroup Archive 2004

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

Search the Archive

Re: doing things on a procedural way and doing them on a functional way

  • To: mathgroup at smc.vnet.net
  • Subject: [mg46988] Re: doing things on a procedural way and doing them on a functional way
  • From: Paul Abbott <paul at physics.uwa.edu.au>
  • Date: Thu, 18 Mar 2004 04:38:04 -0500 (EST)
  • Organization: The University of Western Australia
  • References: <200403170729.CAA16380@smc.vnet.net> <c3bgd8$7q2$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

In article <c3bgd8$7q2$1 at smc.vnet.net>,
 Andrzej Kozlowski <akoz at mimuw.edu.pl> wrote:

> I guess a little self-advertisement is not a major offence on this 
> list, so I suggest looking at my article in the forthcoming Mathematica 
> Journal. If you can't wait you or don't have a subscription you can 
> download it form
> 
> <http://www.mimuw.edu.pl/~akoz/Mathematica/AlgebraicProgramming.nb>

Nice article.

Here is another approach for this particular problem:

 l = {a, b, c, d, e};

 Flatten[Nest[
  Flatten[ReplaceList[#, {a___,b_,c_,d___} :> {a,{b,c},d}]& /@ #, 1]&, 
   {l}, Length[l]-1], 1] // Union

I can't help but feel that there should be an elegant way to do this 
using Distribute ...

Cheers,
Paul

-- 
Paul Abbott                                   Phone: +61 8 9380 2734
School of Physics, M013                         Fax: +61 8 9380 1014
The University of Western Australia      (CRICOS Provider No 00126G)         
35 Stirling Highway
Crawley WA 6009                      mailto:paul at physics.uwa.edu.au 
AUSTRALIA                            http://physics.uwa.edu.au/~paul


  • Prev by Date: Re: Lists
  • Next by Date: Re: Creating a symmetric matrix
  • Previous by thread: Re: doing things on a procedural way and doing them on a functional way
  • Next by thread: Re: doing things on a procedural way and doing them on a functional way