simple list indexing question

hi, how do i index a multidimensional list in steve?

as in

weights{i}{j}{k} = (random[2.0]) - 1.

or

weights{{i}{j}{k}} = (random[2.0]) - 1.

thanks,

nick

the first option

The first option is the one you want -- the second is not valid steve syntax.

- jon

thanks. sadly, this code

thanks. sadly, this code still doesn't seem to work. this is intiialisation code, in '+ to init'

the 2 lists have been declared in + variables and this is the first time thay are assigned to

i get errors for both 'nodes' & 'weights' saying the index is out of bounds (even at '0') .

am a bit baffled...any thoughts? cheers :-)

weights, nodes, senseData, tempList (list).

for i=0, i for j=0, j nodes{i}{j} = 0.
for k=0, k<(spineLength - 1), k++: {
weights{i}{j}{k} = (random[2.0] - 1).

}
}
}

initialize the empty nested lists

If I'm understanding the question right, you need to initiaize the nested lists. So before using nodes{ i }:

nodes{ i } = {}
nodes{ i }{ 0 } = 0

And for weights you want to initialize two nested lists deep:

weights{ i } = {}
weights{ i }{ j } = {}
weights{ i }{ j }{ 0 } = ...

There are other variations on this that would do the trick, but the idea is the same:

nodes = { {}, {}, {} }

- jon

thanks thats done the trick

thanks thats done the trick

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.