Problems with “keep”

I’m trying to make the opposite of the “keep” block but I can not get it to work


Outside of a custom block it works fine
But the second I make it into a custom block it doesn’t

I’ve tried a few things but I’ve concluded that I would need to know how the block works (what system is uses to get its results) to be able to fix it further

I created my own definition for the block but I’d prefer to use the “keep” block as that one is just simply more stable

Here is a solution:
untitled script pic - 2023-05-11T100925.640

I always forgot about the change to the join block -_-
Why wouldnt run with inputs work tho

untitled script pic - 2023-05-11T101446.409
This one allows for usage of (value, index, array).

What's wrong with the most obvious
untitled script pic - 2023-05-11T234231.203

.
untitled script pic - 2023-05-11T234253.671

untitled script pic - 2023-05-12T002618.105
untitled script pic - 2023-05-12T003141.530

Hint:
untitled script pic - 2023-05-12T004539.337
untitled script pic - 2023-05-12T004544.316
untitled script pic - 2023-05-12T004550.183
untitled script pic - 2023-05-12T004630.812

For a more general approach
I made a function that groups all items by result of a function applied to each item.
E.g. it can divide a list of numbers into a list of primes and one of non-primes:

... or multiple sublist, grouped by a number's smallest divisor:

This is the implementation code
It will determine the result of the function only once for each item, and no (relatively inefficient) CONTAINS operation is required.

Programming tools SANDBOX script pic (46)

Update
I found a library block doing the same thing as my GROUP BY function (but slightly better); unsurprisingly it's called Programming tools SANDBOX script pic (50); it's in the Frequency Distribution Analysis library.

Very cool!
Unrelated note: I personally prefer “recall [] as (i)” rather than “let [] be (i)”

I think the word "let" describes what the block does pretty well. Check out MDN's description of the functionality of "let" in JavaScript.

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