#(LeafyMitsuwa) List logic

18 messages · Page 1 of 1 (latest)

fiery escarp
#

I've come to the realization that I'm overthinking a piece of logic parsing, so I'd like to ask for input.

I'm working with a list, this list has 9 entries with integers.
i.e. <list[8|8|0|8|16|0|0|0|0]>

What I am trying to accomplish, is to eliminate any 0 from the end.

My current logic:

    # Reverse the list so we start checking from the end.
    - foreach <[list].reverse>:
        # Set a value to determine if we've reached a value larger or equal than 1.
        - if <[trigger].if_null[false]>:
            - define WorkbenchInputQuantity:->:<[value]>
            - foreach next
        - if <[value]> >= 1:
            - define WorkbenchInputQuantity:->:<[value]>
            - define trigger true
naive oasisBOT
#

Hi I'm AutoThreadBot! Don't mind me, I'll just be adding the helper team to this thread so they can see it. A human will get to you soon.
You can block this bot if you don't want to see these messages, I won't mind.
<@&525394568410038282>

fiery escarp
#

What I am trying to accomplish, is to eliminate any 0 from the end. --> is to eliminate any 0's from the end, until a non-0 integer is found,

So, <list[1|1|1|1|0|1|1|0|1]> needs to stay as-is, and <list[1|0|1|1|0|1|0|0|0]> needs to become <list[1|0|1|1|0|1|]>

brittle elk
#

i dont understand your snippet, but i feel like this effectively "removes any zeroes if they are the last value in a list"?

- while <[list].last> == 0:
  - define list <[list].remove[last]>```
fiery escarp
#

Ye, I did a poor job explaining. 0's are fine. I want all the 0's at the end removed until a non-0 integer is found.

hot forge
#

will the list in the while statement get updated as well? O.o

brittle elk
fiery escarp
#

Perfect. Just gave it a test.

#

Thanks.

brittle elk