MathGroup Archive 2007

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

Search the Archive

Re: Variable-length list?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg83497] Re: Variable-length list?
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Wed, 21 Nov 2007 03:05:41 -0500 (EST)
  • Organization: Uni Leipzig
  • References: <fhu73f$71m$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de

Hi,

Strange[m : {__Integer}] :=
  Module[{ii},
   ii = Table[Unique["blub$"] , {Length[m]}];
   Table[Times @@ ii, Evaluate[Sequence @@ Transpose[{ii, m}]]]
   ]

??

Regards
   Jens

Hoa Bui wrote:
> Hi all,
> 
> I want to have either a module or a function that inputs a
> varying-length list M[[nx]], where nx is a parameter, and accesses all
> of its elements.
> 
> For example:
> 
> f[M_?(Function[v,VectorQ[v,IntegerQ]]]:=Module[{i,j,k},
> ...
> ]
> 
> If M={3,4} then f would do something like:
> For [i=1,i<3,i++,
> For [j=1,j<4,j++,
> Print[i*j];
> ]
> ]
> 
> If M={3,4,5} then:
> For [i=1,i<3,i++,
> For [j=1,j<4,j++,
> For [k=1,k<5,j++,
> Print[i*j*k];
> ]
> ]
> ]
> ]
> 
> 
> I wonder if this is doable in Mathematica, and/or what would be a way to do it?
> 
> Thanks a lot,
> Hoa
> 


  • Prev by Date: Re: Scalars Instead of Lists with One Element
  • Next by Date: Re: Variable-length list?
  • Previous by thread: Re: Variable-length list?
  • Next by thread: Re: Variable-length list?