# max and min reporters

I can't find any max or min reporters in the libraries

Does Snap! have them?

what do you want them to do?

The APL library includes them, but that may be more heavyweight than you want.

1 Like

When I was playing around with pixels for @glenbull question, I wanted to add 128 to a red value of a pixel but make sure the result didn't exceed 255.

oh, ok, well, that's easy to make

and you use < instead of > to make min

2 Likes

max %max of %value

This terminology needlessly privileges one particular use case of what is, in fact, a commutative function. It should be max of %a and %b or something. Or just max %a %b.

1 Like

max %list

1 Like

That's an idea

You can also use combine with the two input reporter to get the same result.

Not sure how to do that - could you post a pic of a script to do that?

It uses the max block with two inputs that ego-lay_atman-bay wrote earlier

1 Like

I think @18001767679 was suggesting rather than . There aren't very many cases in which you need the maximum of exactly three, or exactly four, values -- or any specific number other than two. It's much more common that you've imported some data and you need the maximum of however many records it has. So you might as well make that clear in the way you build the block.

The alternative approach of building a two-number version and then using COMBINE to make the list version is how I always do it, because it's easy to make the two-input version functionally:

1 Like