Bugs ? What is logic?

image

Of those, only the last one might be a bug.

For the first one, format as decimal returns a string with the number formatted to the specified number of decimal places.

For the second, is number? checks that its input could be interpreted as a number. This is trivially true for numbers, but it is also true for strings that look like numbers (e.g., the output of format as number).

For the third, is binary? checks that its (text) input looks like a binary number (i.e., a string in [0,1]+). But binary 1101 is the decimal number 13, so as a string it is not a binary number.

That last one is wierd in English too.

Correct. The issue is that there are really a few different list types in App Inventor internally. There's sort of your standard Java list types, there is Scheme's list type, and then there is App Inventor's list type. The is a list? block expects a list of the latter form, but the mode of a list block actually returns the Scheme list type, resulting in the mismatch between the expected result (true) and what we observe in the example (false). The code will have to be corrected to return the App Inventor list type instead.

There is also the question of should a unique mode result be a list or a scalar?

This is something we discussed internally when creating the block. Ultimately, we think it made more sense for the return type to be consistent (it's always a list of 0 or more elements), rather than having a chance that sometimes it's a list and sometimes it's a number. In this latter scenario, the user would have to check the return type after every invocation to know whether they can use the value immediately because it's a number or unpack the list if it was a list.

1 Like

The name modes would express that return type in English.

But a tool tip update would avoid a nomenclature fight.

1 Like

Thank you for your reply.

Here is the blocks version of the mode function (draggable)


and a test run:
modes_test

Thank you for a fun post!

Good example for Make new filtered list !

Why does it give me an error?

Is the first value in your text the letter O or the number 0?

It is the number Zero


Sorry for the confusion, it turns out that I'm using an older version of companion (2.65u)

2 Likes