I'm writing an implementation of SRFI-1 in _javascript_ (just for fun) and I have a question about SRFI-1's any procedure. In the docs it says that "(any) does not return a simple boolean (#t or #f), but a general value", however it also says that any must be called with a "procedure taking n arguments and returning a boolean result".
I've been testing my implementation against Chicken for correctness and here's what I get on Chicken:
For #3 and #4 any correctly returns #t and #f respectively. However for #2 shouldn't any return 2 instead of, what I'm assuming is, (void)? What is the correct behavior here?
From SRFI-1:
any pred clist1 clist2 ... -> value
Applies the predicate across the lists, returning true if the predicate returns true on any application.
If there are n list arguments clist1 ... clistn, then pred must be a procedure taking n arguments and returning a boolean result.
any applies pred to the first elements of the clisti parameters. If this application returns a true value, any immediately returns that value. Otherwise, it iterates, applying pred to the second elements of the clisti parameters, then the third, and so forth. The iteration stops when a true value is produced or one of the lists runs out of values; in the latter case, any returns #f. The application of pred to the last element of the lists is a tail call.
Note the difference between find and any -- find returns the element that satisfied the predicate; any returns the true value that the predicate produced.
Like every, any's name does not end with a question mark -- this is to indicate that it does not return a simple boolean (#t or #f), but a general value.