groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul King <>
Subject primitive array variants for some DGM methods
Date Thu, 17 Dec 2020 02:42:21 GMT
Hi everyone,

I was going to add some primitive array variants for some of our DGM
For instance, we currently have:

public static <T> T min(T[] self) {
    return min(toList(self));

This will work for Integer[] but not int[] for instance and while idiomatic
Groovy might use the wrapper types in most places, the primitives come up
enough with data science libraries that I think it is worth providing
special support. I was thinking we might be able to be smart and
automatically generate the primitive ones but there seems to be enough edge
cases that it might not always give what you want, e.g. the above returns
null for an empty array. So, I'll refrain from that path for now but if
anyone wants to explore that option we can refactor at a later date.

Cheers, Paul.
P.S. The above case also needlessly creates a list. Sure it avoids some
code duplication but I think efficiency should come first here, so I'll
likely refactor examples like that away too at the same time.


View raw message