groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul King <pa...@asert.com.au>
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
methods.
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.


<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

Mime
View raw message