MathGroup Archive 2003

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

Search the Archive

Re: Q: lists

  • To: mathgroup at smc.vnet.net
  • Subject: [mg40066] Re: [mg40063] Q: lists
  • From: Dr Bob <drbob at bigfoot.com>
  • Date: Tue, 18 Mar 2003 05:49:47 -0500 (EST)
  • References: <200303180721.CAA12255@smc.vnet.net>
  • Reply-to: drbob at bigfoot.com
  • Sender: owner-wri-mathgroup at wolfram.com

First, I'll give you what you asked for:

data = {3, {1, 2, 3, 4}};

f[{a_, {b__}}] := Times @@ ({a, #} & /@ {b})
f[data]

{81, 24}

But this is probably what you really wanted:

g[{a_, {b__}}] := {a, #} & /@ {b}
g@data

{{3, 1}, {3, 2}, {3, 3}, {3, 4}}

Bobby

On Tue, 18 Mar 2003 02:21:38 -0500 (EST), Dick Barends 
<dick.barends at wxs.nl> wrote:

> Hello,
>
> I want to tranform the list below:
>
> {3,{1,2,3,4}}
>
> into
>
> {3,1}{3,2}{3,3}{3,4}
>
> How can I do this?
>
> kind regards
> Dick
>
>
>
>



-- 
majort at cox-internet.com
Bobby R. Treat



  • References:
    • Q: lists
      • From: "Dick Barends" <dick.barends@wxs.nl>
  • Prev by Date: Re: Q: lists
  • Next by Date: Re: Automatic detection for application of NSolve or FindRoot
  • Previous by thread: Q: lists
  • Next by thread: Re: Q: lists