Burkhard
03/26/2020, 9:40 AMIterable.sum()
that multiplies instead? I know I can use reduce to get the same effect, just looking for a cleaner way to code this.Michael de Kaste
03/26/2020, 9:47 AMspand
03/26/2020, 10:40 AMproduct
would fairly quickly overflowBurkhard
03/26/2020, 10:41 AMBigInteger
so I should be fine 😉Kroppeb
03/26/2020, 12:19 PMKroppeb
03/26/2020, 12:20 PMmax()
in python returns negative infinityBurkhard
03/26/2020, 12:24 PMMichael de Kaste
03/26/2020, 12:26 PMKroppeb
03/26/2020, 12:27 PMMichael de Kaste
03/26/2020, 12:27 PMMichael de Kaste
03/26/2020, 12:28 PMKroppeb
03/26/2020, 12:29 PM(1..n).product()
to return n!
and 0! = 1
, 1..0 = emptyList()
Burkhard
03/26/2020, 12:30 PMKroppeb
03/26/2020, 12:32 PMKroppeb
03/26/2020, 12:35 PMKroppeb
03/26/2020, 12:35 PMMichael de Kaste
03/26/2020, 12:37 PMdefault
implementation
So make it as you wish 🙂Burkhard
03/26/2020, 12:40 PMMichael de Kaste
03/26/2020, 12:45 PMval result = someList.someReductionFunction()
when(result){
null -> doThingForEmptyList()
else -> doThingWithResult(result)
}
they could also check for the size of the list before reduction, so I don't really agree with this implementation for all works, but I've seen plenty of programmers being stubborn at least 😆