type ITree
    n::Int
    children::Union(Vector{Int},Vector{ITree})
end

julia> t = ITree(123, [1,2,3])
ITree(123,[1,2,3])

julia> ITree(234, [t])
ITree(234,[ITree(123,[1,2,3])])

On Sat, Jun 27, 2015 at 10:50 AM, <[email protected]> wrote:

> I am new to Julia with mostly C and some MATLAB background.  Julia seems
> to provide an easy way to write C like code with MATLAB ease!  To get
> started, I am trying understand C interface. Is it be possible to create a
> Julia type for the following struct?
>
> typedef struct itree {
>   bool isLeaf;
>   int n; //number of elements
>   union {
> int *i; //(isLeaf == 1): pointer to int array
> struct itree **s; //(isLeaf == 0): pointer to itree array
>   };
> } itree;
>
> It seems, that the size of the pointer should be the same. So, anonymous
> union should be possible.
> I would appreciate any suggestions.
>
> Thanks,
> ~Sue
>
>

Reply via email to