help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

create variable with name from string?


From: Malte Köster
Subject: create variable with name from string?
Date: Sun, 30 Mar 2008 00:26:49 +0100

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]