Proposal to reduce the number of argument to array-for-each, array-every, and array-any Bradley Lucier 08 Nov 2025 21:32 UTC

The calling sequence for array-for-each, array-every, and array-any are
currently

Procedure: array-for-each f array . arrays
Procedure: array-every predicate array . arrays
Procedure: array-any predicate array . arrays

Because array-map always returns a generalized array, these could be
replaced simply by:

Procedure: array-for-each array

Evaluate array's getter for every multi-index in its domain, in order.
Unspecified value is returned.

Procedure: array-every array

Evaluate array's getter for each multi-index in its domain, in order.
If every result is non-false, return the last result, otherwise return
the first #f.

Procedure: array-any array

Evaluate array's getter for each multi-index in its domain, in order.
If every result is #f, return #f, otherwise return the first non-false
value.

The old behavior can be obtained with

(array-for-each (apply array-map f array . arrays))
(array-every (apply predicate array arrays))
(array-any (apply predicate array arrays))

And in fact, that's basically what the current implementation does under
the hood.

I noticed this after studying Racket's math/array library and thinking
about how best to implement array broadcasting in an extension to SRFI
231.  And the best way to implement broadcasting is to avoid
implementing it at all for anything but array-map, array-fold-left and
array-fold-right.

I'm inclined to make this simplifying change.

Comments?

Brad