No permutations function in the library?

Is there a permutations function in the library? If not there should be. I have been tinkering with a function relating to permutations are words for anagrams and also there is A handful of Kotlin permutations. Lately I have been having an enormous… | by Daniil Vodopian | Medium

1 Like

Generally, “It should be” is not sufficient motivation to add something to the standard library. We have a goal to keep the library small and include only those APIs which have enough use cases and would be beneficial to the significant part of language users.

The API to be included in the standard library must go through some proposal and review process. We had recently set up such a process (KEEP). If you have an idea for a new API you can create your own proposal and file it as a pull request to KEEP repository.
Thanks to the [template] (KEEP/TEMPLATE.md at master · Kotlin/KEEP · GitHub) composing such a proposal becomes quite straightforward. We have written some proposals by ourselves and have already received a couple of proposals from the community Issues · Kotlin/KEEP · GitHub.

Once they are baked enough, we’ll discuss them and include their implementations in the library.

1 Like

I’ll take a look at this next month.

Clearly stuff can go into artefacts in Bintray and Maven Central and it is easy to use given Gradle or Maven. So having smaller core library is not as big a deal as it can be in other languages.

There is a language marketing issues here to bear in mind. If Kotlin is to get into data science there needs to be a good quality library with all this stuff in.

The “should be” really comes from Python where all this stuff is in the standard library. People doing Python → Kotlin will have a lot of surprises.

@Russel my point of view on this is that a bunch of python-like capabilities should be included in a “math” module in kotlinx (not the stdlib). I planed to examine a bunch of languages famous for their math/scientific applications, namely Python/Matlab/R# and collect the most useful parts into a library. We may join forces if you are interested.

1 Like

If there was to be a kotlinx.XXX (where XXX is some suitable name) and it was being managed as effectively a rolling release to somewhere that Gradle (and Maven?) could pick it up then I think this is a splendid idea. Obviously in the Python world (I do not know the R or Matlab worlds) there is NumPy (not as good as people make out just now, but could be again) and then all the SciPy, Pandas, Matplotlib, Scikit/Learn stuff built on NumPy and other bits of Python. There are person centuries of code in there which is why for data scientists it is “I can do all my stuff with very little effort”. Language like D are looking to see if they can get into this world since D is statically compiled native code and so algorithms are hugely faster than Python/NumPy. My hesitation is that will these people move into a JVM-based world?

1 Like

I’ve quickly created a kotlinx.math project [1] for a start. Don’t hesitate to fork or clone it; this could be eventually forked to the “kotlin” GitHub organization.

@voddan: Is it okay to use the permutation code in your Gist for kotlinx.math?

[1] GitHub - hastebrot/kotlinx.math: Kotlin extensions for math

Cool, I’ll stay in touch!

@hastebrot use the code right away if you think it is useful. I believe it can be optimised for speed and GC using more imperative code without generics

Thanks.

The first goal can be to provide some useful math functions that are fast enough for basic use. A complee math library is a huge effort. I primary use Python libraries like GitHub - sympy/sympy: A computer algebra system written in pure Python and GitHub - fredrik-johansson/mpmath: Python library for arbitrary-precision floating-point arithmetic

If needed there could be additional subprojects for things like statistics, linear algebra and group theory; but these things could maybe overshoot the goal of a small extension library like kotlinx.math.

I believe the first thing to do is to list the things we obviously need at hand. Like support for BigNumber or basic statistic algorithms. We may take those from popular python libraries, for example. A good way to collect the info is to use the issues in the repo. Also let’s discuss that on slack, I created #kotlinx

How to relate this kotlinx.math to the kotlinx-math at kotlin-extensions/kotlinx-math at master · yongjhih/kotlin-extensions · GitHub

Did anything happen with this later?

We have a group of people working on math libraries for kotlin and that have done quite a lot of progress lately. Make sure you check out the slack channels #mathematics and #datascience.

1 Like