Currently, foldr1 only works on lists with length > 1. However, its name and heritage implies that foldr1 should also work on lists of length 1. A possible definition for foldr1, conforming to this idea, is:

foldr1(s) = ?[] <+ ?[x | xs]; (x, <foldr1(s)> xs)

However, I have no idea what impact this change of definition might have. In general, the fold-family in the stratego libraries might benefit from a fresh look and some re-engineering.

Furthermore, foldr1 is marked for internal use only in the documentation, for no apparent reason.

Submitted on 11 May 2007 at 15:46

Log in to post comments