Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #13868 > unrolled thread

Re: variables/objects with sequential naming?

Started by"Louis Talman" <talmanl@gmail.com>
First post2013-03-17 23:48 +0000
Last post2013-03-17 23:48 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: variables/objects with sequential naming? "Louis Talman" <talmanl@gmail.com> - 2013-03-17 23:48 +0000

#13868 — Re: variables/objects with sequential naming?

From"Louis Talman" <talmanl@gmail.com>
Date2013-03-17 23:48 +0000
SubjectRe: variables/objects with sequential naming?
Message-ID<ki5kob$e7g$1@smc.vnet.net>
Try

Do[Evaluate[ToExpression["Graph"<>ToString[k]]] = k^2, {k, 1, 8}]

Note that the "Evaluate" terminates *on the left side* of the Set.

You can leave off the "Evaluate" when you want what's in your variables:

Table[ToExpression["Graph"<>ToString[k]],{k, 1, 8}]



On Sat, 16 Mar 2013 01:15:40 -0600, <northerndream@gmail.com> wrote:

> Dear all,
>
> the simplest way to explain what I'd like to achieve is to show you the  
> long way I had to go, not knowing how to automate this:
>
> graph1 = Graph[cities, DeleteDuplicates@edges[[1]]];
> graph2 = Graph[cities, DeleteDuplicates@edges[[2]]];
> graph3 = Graph[cities, DeleteDuplicates@edges[[3]]];
> graph4 = Graph[cities, DeleteDuplicates@edges[[4]]];
> graph5 = Graph[cities, DeleteDuplicates@edges[[5]]];
> graph6 = Graph[cities, DeleteDuplicates@edges[[6]]];
> graph7 = Graph[cities, DeleteDuplicates@edges[[7]]];
> ...
>
> and I think you got the point (no need to paste the whole list!)
>
> I will of course have the same problem on the way around, when I'll want  
> to obtain a table of values for all my graph1, graph2...
>
> I used ToString to produce output files with sequential names, but  
> this... no clue! (googling didn't help either)
>
> Could anywone help?
> Thank you
> - Stefano
>

--Louis A. Talman
   Department of Mathematical and Computer Sciences
   Metropolitan State University of Denver

   <http://rowdy.msudenver.edu/~talmanl>

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web