Nick Zarr scripsit: > 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".
The latter is clearly in error: the predicate argument to ANY, EVERY, and LIST-INDEX can return any value. The words "and returning a boolean result" should be removed from the specification. > I've been testing my implementation against Chicken for correctness > and here's what I get on Chicken: > > #;2> (any (lambda (x) (if (even? x) x)) '(1 2 3)) > #;3> (any (lambda (x) (even? x)) '(1 2 3)) > #t > #;4> (any even? '(1 3 5)) > #f > > 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? No, that's the difference between ANY and FIND. FIND returns the element which satisfies the predicate, whereas ANY returns what the predicate returns, in this case (void), because that is a true value. Chicken is doing the Right Thing. -- La mayyitan ma qadirun yatabaqqa sarmadi John Cowan Fa idha yaji' al-shudhdhadh fa-l-maut qad yantahi. co...@ccil.org --Abdullah al-Hazred, Al-`Azif http://www.ccil.org/~cowan _______________________________________________ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users