MathGroup Archive 2010

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

Search the Archive

Re: Generate #s

  • To: mathgroup at
  • Subject: [mg111012] Re: Generate #s
  • From: magma <maderri2 at>
  • Date: Fri, 16 Jul 2010 07:00:14 -0400 (EDT)
  • References: <i1p823$pj9$>

On Jul 16, 11:16 am, Francisco Gutierrez <fgutiers2... at>
> Dear Group:
> Suppose I have a list of ordered integers:
> example={1,5,7,9}
> Based on it, I want to generate a list of the form:
> {#[[1]], #[[5]],#[[7]],#[[9]]}
> I tested with simple things like:
> Table[#[[example[[i]]]], {i,1,Length[example]}]
> to no avail.
> How can I do it?

If i understand your question....
it seems you just forgot to put the &, which must appear somewhere
after all.

example = {1, 5, 7, 9} (* list of parts *)
arg = {w, e, r, t, y, u, i, o, p} (*an argument with 9 parts*)
Table[#[[example[[ii]]]], {ii, 1, Length[example]}] &[arg]

will give you

{w, y, i, p}

that is: a list of the first, fifth, seventh and ninth part of the

  • Prev by Date: Re: Generate #s
  • Next by Date: Re: Select only certain sublists matching criteria
  • Previous by thread: Re: Generate #s
  • Next by thread: Re: Generate #s