Is it possible to create a procedure with that returns whether an item is in a list and, if so, removes it?

I would like to create an App Inventor procedure that, like the is in list? block, tests whether a thing is in a list. In addition to returning true or false, I would like to remove the thing from the list if it is present. So far, I haven’t found a way to embed a statement (i.e., a block that doesn’t have a value plug on its left side) inside the block for a procedure returning a value, which expects expressions (blocks that do have value plugs on their left side).

Thank you.

Ellen

You can use this procedure to delete the item from list, if the value is in the list.

blocks (17)

Also you can use this procedure if you want to return the edited list after deleting the value from the list.

blocks (18)

2 Likes

This sounds like the solution to the Original Post:
was_in_list
The blocks should be draggable for import.

6 Likes

The problem statement is a little fuzzy on
duplicate value handling, though.
I remove only the first.

1 Like

P.S.
This is a code version of the World’s Funniest Joke

Here’s a variant that will remove all occurrences.

blocks (20)

4 Likes

Thank you, @ABG and @ewpatton! I see that the do block was the missing link.

2 Likes