Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*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 2000

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

Search the Archive

RE: RE: Expanding a nested structure (pattern matching?)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg24877] RE: [mg24855] RE: [mg24835] Expanding a nested structure (pattern matching?)
  • From: "David Park" <djmp at earthlink.net>
  • Date: Sat, 19 Aug 2000 04:45:51 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

[From Hartmut Wolf]
> Also redefining...
>
> dsb2[h_List] := Flatten[h]
> dsb2[h_ /; MemberQ[h, {___}]] := Distribute[h, List]
> dsb2[a_] := a
>
> dsb2 //@ e4
> {f[a, c1], f[a, c2], f[a, d1], f[a, d2], f[b, c1], f[b, c2], f[b, d1],
>   f[b, d2]}
>

Dear Hartmut,

That seems like a nice solution. And I was blithely unaware of MapAll!

Here is a somewhat more complete list of examples. John communicated with me
and gave a case with variable numbers of and lengths of lists.

e1 =  a[b, c, d[{f, g}, {h, j}]]
e2 =  a[b, c, d[e, f[{f1, f2}, {f3, f4}]]]
e3 =  a[b, c[{c1, c2}, {c3, c4}], d[e, f[{f1, f2}, {f3, f4}]]]
e4 = f[{a, b}, {{c1, c2}, {d1, d2}}]
e5 = a[b, c, d[e, f[{f1, f2}, {f3, f4, f5}, {f6, f7}]]]
e6 = a[b, c[{c1, c2}, {c3}], d[e, f[{f1, f2}, {f3, f4, f5}, {f6, f7}]]]

On the last case, your method was more than 10 times faster than my
procedure.

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/



  • Prev by Date: Re: Using FindRoot
  • Next by Date: Re: REQUEST: Are there any notebooks or packages about Bayesian data analysis?
  • Previous by thread: RE: Expanding a nested structure (pattern matching?)
  • Next by thread: Re: Expanding a nested structure (pattern matching?)