MathGroup Archive 2002

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

Search the Archive

RE: Enhance a function that involve list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg36039] RE: [mg36004] Enhance a function that involve list
  • From: "David Park" <djmp at earthlink.net>
  • Date: Tue, 13 Aug 2002 05:23:03 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Guillermo,

You could use something like this...

function2[f_][list_] := MapThread[f @@ list[[#1]] & ,
   {Flatten[Table[{i, j, j + 1}, {i, 2, Length[list]},
      {j, 1, i - 1}], 1]}, 1]

list = {a1, a2, a3, a4};

function2[f][list]
{f[a2, a1, a2], f[a3, a1, a2], f[a3, a2, a3], f[a4, a1, a2], f[a4, a2, a3],
  f[a4, a3, a4]}

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



From: J. Guillermo Sanchez [mailto:guillerm at usal.es]
To: mathgroup at smc.vnet.net


Dear friends
I wish to build a function to obtain from a list (i.e.:)

list = {a1, a2, a3, a4};

and output like this:

{{f[a2, a1, a2]},
{f[a3, a1, a2], f[a3, a2, a3]},
{f[a4, a1, a2], f[a4, a2, a3], f[a4, a3, a4]}}

This following function work fine


function1[tau1_] :=
  Table[Table[
      f[Extract[tau1, j + 1], Extract[tau1, i], Extract[tau1, i + 1]],
{i, 1,
        Length[tau1] - Length[tau1] + j}], {j, 1, Length[tau1] - 1}]

function1[list] // TableForm


but I think is not so eleghant. I will appreciate any  help to build a
more effecient and eleghant solution

Guillermo Sanchez




  • Prev by Date: Re: How to simulate the Doppler Effect ?
  • Next by Date: Re: Re: One to the power Infinity
  • Previous by thread: Re: Enhance a function that involve list
  • Next by thread: Re: Enhance a function that involve list