create variable with name from string?
Malte Köster
m.koester at jacobs-university.de
Sat Mar 29 18:26:49 CDT 2008
Hi there!
I was wondering if there is a way to create a variable with a name
that is read from a string.
For example I'm reading a file that is a shopping list. The first
line of the file specifies a category, after that it contains items
belonging to the category:
fruits
apple
peach
banana
I want to read the file, and save the information in a data structure
like
items_to_buy =
{
fruits =
{
apple
peach
banana
}
}
So before I read the file I don't know that I want to call my
variable "fruits". I want to read this varibale name from some string.
Hope I could make a bit clear what I mean.
Of course there's many ways to work around this, but I was wondering
if it is possible to do something like this.
cheers,
malte
More information about the Help-octave
mailing list