Thank you both. I'll have a look at a recursion approach.
On Thursday, 7 January 2016 13:47:02 UTC, Tim Holy wrote: > > This is a problem for recursion. See, for example, the LightGraphs or > Graphs > packages. > > Best, > --Tim > > On Thursday, January 07, 2016 02:10:18 AM Asbjørn Nilsen Riseth wrote: > > I would like to loop over all the \beta_i values of the following tree. > > > > < > https://lh3.googleusercontent.com/-EBjanFs-BC4/Vo409IFAiTI/AAAAAAAAMEw/U7iq > > Ev9nPmU/s1600/tree.png> > > > > What is the best Julia way of doing this? I'm also interested in > > generalising this to N levels. > > > > > > For the given tree, the following works. *Is there a way to use @nloops > to > > shorten this?* > > n = Int(1/0.2) > > for i_3 = 0:n > > for i_2 = 0:n-i_3 > > for i_1 = 0:n-i_2-i_3 > > i_0 = n-sum(@ntuple 3 i) > > β = [i_3, i_2, i_1, i_0]/n > > @show β > > end > > end > > end > >
