MathGroup Archive 2003

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

Search the Archive

Re: Q: lists


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



  • 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