Deep index of a nested list

I'm wanting to return an index (I like to think of it being a pointer) to an item in a nested list

But, I wondering, has this already been done?

Using this example structure:

deepListExample

what I'm looking for is returning something like

indexA
indexC
indexE

Here's what I did a while ago. Do these work for you?
Blocks

:slight_smile: (Used wrong images in previous post!)
path is exactly what I was after :slight_smile:

pathA
pathE

but I was expecting this to just return E
item321

Oh, thats a variadic input slot! I thought It would make it easier to directly type the numbers in if you need to, otherwise you have to drop the list on top of the arrows

aah - got you :slight_smile:

edit you must have a better mouse than me to drop a list onto those arrows !!! :slight_smile:

Hah no, I had the same problem. Collapsing all the slots first did the trick for me but I guess I will just make it a list input :]

That will probaby what'll I use...

but...

I decided to try putting path at the end (so it would be easier to drop onto the arrows and keep) and changing syntax but everytime I try to do this - I end up with an error

Are you able to make it work this way
e.g in list find path

Like this?:
untitled script pic (11)
Its a recursive function, so when you change the order of the inputs slots you'll also have to change the inputs when it calls itself. Hope it helps!
Edit: this indeed makes it easier, thanks

Of course! Silly me! :laughing:

Perfect :slight_smile:

inFind321

I've been having a play around, as I decided I was conflicted with the
in [] find input list []
syntax as that could imply that the block searches for the 2nd list within the first one

But I had this idea - turn it into a two liner and add some extra description

itemFromPath

which I think makes it explicit that its not like the native item () of []

It's then no problem to drop a path list onto it :slight_smile:

itemFromPathExample

I've been trying out lots of stuff (but recursion is my weak point in computing) in attempting to get ALL the indices of a search item in a deep list.

I managed to get all the indices of a search item in a simple list
indexIndicesDeepIndex script pic

[update] 14Sep2022 finally managed to produce one that works without using a kludge :slight_smile:

[update2 14Sep2022 - mm - not quite there yet - doesn't find the 3rd A :frowning:

[update 15Sep2022 - I think (I know I've said it before!) that this one will find all indices wherever they appear in a list

Works on the previous test case and all others I've tried it

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.