[m-dev.] behaviour of array.map_corresponding_foldl

Julien Fischer jfischer at opturion.com
Mon Aug 13 21:14:05 AEST 2018


Hi,

The documentation for array.map_corresponding_foldl/6 currently says:

     map_corresponding_foldl(P, A, B, C, !Acc):

     Given two arrays A and B, invoke P(Aelt, Belt, Celt, !Acc) on
     each corresponding pair of elements Aelt and Belt. Build up the array C
     from the result Celt values. Return C and the final value of the
     accumulator.

     C will have as many elements as A does. In most uses, B will also have
     this many elements, but may have more; it may NOT have fewer.

I would note that (1) the final condition is not checked at all and
since the array lookups inside map_corresponding_foldl are unsafe, all
sorts of interesting things may happen if B does have fewer elements
than A and (2) all of the other "corresponding" predicates in the
standard library throw an exception if the things that are supposed to
correspondg do not in fact correspond.

Are there any objections to changing array.map_corresponding_foldl to
do the same?

Julien.


More information about the developers mailing list