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: [mg47001] Re: doing things on a procedural way and doing them on a functional way
  • From: drbob at bigfoot.com (Bobby R. Treat)
  • Date: Fri, 19 Mar 2004 01:35:54 -0500 (EST)
  • References: <200403170729.CAA16380@smc.vnet.net> <c3bgd8$7q2$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

There are a lot of really good ideas in the AlgebraicProgramming
notebook. Thanks for sharing! However...

I think you mean your answer to "Suppose g is a nonassociative
noncommutative product..." to be a solution to the posted problem.

ClearAll[f]; SetAttributes[f, {Flat, OneIdentity}]
FixedPoint[Union[Flatten[ReplaceAllList[#1, f[a_, b_] -> g[a, b]]]] &
,
   f[a, b, c, d]]; 
Union[% /. f -> g]
{g[a, g[b, g[c, d]]], 
  g[a, g[g[b, c], d]], 
  g[a, g[b, c, d]], 
  g[g[a, b], g[c, d]], 
  g[g[a, g[b, c]], d], 
  g[g[g[a, b], c], d], 
  g[g[a, b, c], d]}

But this result includes g[a,b,c] and g[b,c,d] which are not binary
products. Do you mean us to remove elements that include more than
binary products?

Bobby

Andrzej Kozlowski <akoz at mimuw.edu.pl> wrote in message news:<c3bgd8$7q2$1 at smc.vnet.net>...
> 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>
> 
> Andrzej Kozlowski
> 
> On 17 Mar 2004, at 08:29, Pedrito wrote:
> 
> > Hello Mathgroup!
> >
> >
> > I wanted to figure how to obtain all the possible combinations of five
> > numbers and four non-conmutative non-asociative operations.
> >
> > This means:
> > if we have numbers: a b c d e
> > and the non-conmutative non-asociative operation:  ?
> >
> > it's possible to make the following (different) expressions:
> > a ? (b ? (c ? (d ? e)))
> > a ? (b ? (c ? d) ? e))
> > ...
> > (a ? b) ? (c ? d) ? e
> >
> >
> > For practical reasons you can think that the operation ? is ^ (power).
> >
> >
> >
> > I have already obtained (by hand) all the possible combinations:
> >      lst={{a, {b, {c, {d, e}}}}, {a, {b, {{c, d}, e}}}, {a, {{b, c}, 
> > {d,
> > e}}}, {a, {{b, {c, d}}, e}}, {a, {{{b, c}, d}, e}}, {{a, b}, {c, {d, 
> > e}}},
> > {{a, b}, {{c, d}, e}}, {{a, {b, c}}, {d, e}}, {{{a, b}, c}, {d, e}}, 
> > {{a,
> > {b, {c, d}}}, e}, {{a, {{b, c}, d}}, e}, {{{a, b}, {c, d}}, e}, {{{a, 
> > {b,
> > c}}, d}, e}, {{{{a, b}, c}, d}, e}}
> >
> >     And then I transformed them into an expressions by:
> > Module[{x = 1},
> >       ToExpression[
> >         StringReplace[
> >           ToString[#1], {"{" -> "(", "}" -> ")",
> >             "," :> {"^", "^", "^", "^"}\[LeftDoubleBracket]
> >                 x++\[RightDoubleBracket]}]]] & /@ lst
> >
> >
> > If you can help me to do it better...
> >
> >
> > Pedro L.
> >
> >


  • Prev by Date: Re: Re: Integrate vs NIntegrate
  • Next by Date: RE: Re: doing things on a procedural way and doing them on a functional way
  • Previous by thread: Re: doing things on a procedural way and doing them on a functional way
  • Next by thread: Re: Re: doing things on a procedural way and doing them on a functional way