No default value for array-reduce on empty arrays Bradley Lucier (13 Jun 2022 17:13 UTC)
Re: No default value for array-reduce on empty arrays Alex Shinn (13 Jun 2022 21:44 UTC)
Re: No default value for array-reduce on empty arrays Per Bothner (13 Jun 2022 22:49 UTC)
Re: No default value for array-reduce on empty arrays John Cowan (14 Jun 2022 11:28 UTC)
Re: No default value for array-reduce on empty arrays Marc Nieper-Wißkirchen (14 Jun 2022 11:41 UTC)
Re: No default value for array-reduce on empty arrays John Cowan (14 Jun 2022 11:53 UTC)

No default value for array-reduce on empty arrays Bradley Lucier 13 Jun 2022 17:13 UTC

I'd like to point out that there is no default value for array-reduce on
empty arrays for any operator.  I couldn't figure out a reasonable way
to provide one, short of something like an alist with

+ -> 0
fx+ -> 0
fl+ -> 0.0
* -> 1
fx* -> 1
fl* -> 1.0

etc.  (Although I can't imagine right now what other entries might be in
the table.) This affects array-inner-product, too.

array-fold[l|r] returns what I call the "identity" argument for empty
arrays.  But you can't pass such an argument to reduce.

Brad