Le dimanche 01 février 2015 à 01:24 -0800, alex codoreanu a écrit :
> Thanks Milan,
>
>
> I defined Element as you suggested and created
>
>
> data=(Element, 2)
What is this line supposed to do? All it does now is assign a tuple
containing the Element type, and the integer value 2.
If you want to create an Element instance, you should do e.g.:
element = Element("a name", [1, 2], [2, 3])
and then to create a list holding two Elements, and fill the first value
with the just created element:
data = Vector(Element, 2)
data[1] = element
Accessing members:
data[1].lambda
Regards
> but
>
>
> julia> data[1].lambda=[1., 2.0]
>
> ERROR: type DataType has no field lambda
>
>
>
> Now that I have the structure data how do I access the branch members?
>
>
>
>
> On Sunday, February 1, 2015 at 8:07:51 PM UTC+11, Milan Bouchet-Valat
> wrote:
> Le dimanche 01 février 2015 à 00:35 -0800, alex codoreanu a
> écrit :
> > Hi all,
> >
> >
> > I'm a new Julia user and I'm starting to write a high-level
> multi data
> > type fits file reader and writer akin to IDL's
> mwrfits/mrdfits. I got
> > most of the dynamics figured out by I can't quite make a
> custom
> > structure. For example, I would like something like:
> >
> >
> > element = {name::string, lambda::[float_array, 5000
> elements],
> > flux::[float_array, 5000 elements]}
> >
> >
> > structure = replicate(element, 500)
> >
> >
> > where structure inherits the members of element and can be
> called,
> >
> >
> > structure[1].name = the name of element 1
> > strucutre[1].lambda[1] = the first lambda element of the
> first
> > structure
> Looks like a composite type would work:
>
> type Element
> name::UTF8String
> lambda::Vector{Float64}
> flux::Vector{Float64}
> end
>
>
>
> Regards
>