Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

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

Search the Archive

Re: List manipulation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg73257] Re: [mg73248] List manipulation
  • From: Stern <nycstern at gmail.com>
  • Date: Fri, 9 Feb 2007 02:15:50 -0500 (EST)
  • References: <200702080848.DAA05054@smc.vnet.net>

It occurs to me that you may not be familiar with anonymous functions,
in which case the 'f' in my previous example would not translate
smoothly for you to working code. Consider the following, in which I
use the 'Total' function instead of a generic 'f' :

liste = {{a1, a2, a3}, {b1, b2, b3}, {c1, c2, c3}};

Map[Total[#] &, Map[Union[#, {e}] &, liste]]

   -> {a1 + a2 + a3 + e, b1 + b2 + b3 + e, c1 + c2 + c3 + e}

Cheers,

Michael


On 2/8/07, sepp <gary.larson at gmx.at> wrote:
> hello,
> I would like to combine list elements in the following way:
>
> I have a list with
> liste={{a1,a2,a3},{b1,b2,b3},{c1,c2,c3},.....}
> and a single element {e}
>
>
> I would to add the element {e} to each sublist to get something like
> liste_new={ {a1,a2,a3,e},{b1,b2,b3,e},{c1,c2,c3,e},.....}
> so that finally I can apply a function f on the list
> liste_manipulated={f[ {a1,a2,a3,e}],f[{b1,b2,b3,e}],f[{c1,c2,c3,e}],.....}
>
> I had a look at thread, mapthread, inner, outer, but nothing really
> seems to fit...
> thank you in advance for useful comments!
>
>
>


  • Prev by Date: Re: List manipulation
  • Next by Date: Re: List manipulation
  • Previous by thread: Re: List manipulation
  • Next by thread: Re: List manipulation