Hi All,
Here are three SIP proposals that I came across while doing a deep dive on Scala over the past few weeks (I am looking for remote work as my company Adligo contact [email protected] if your interested )
I have given the proposals the temporary ids for sake of discussion;
Adligo .SIP?. A , Adligo .SIP?. B , Adligo .SIP?. C
Adligo .SIP?. A ) This is a simple idea to combine the âmapâ and 'filter â methods into a single method âconvertâ in order to reduce the number of traversals from two to one in certain scenarios as follows;
map[A] takes ( A => B) and returns either a Iterator[B] or collection[B]
filter[B] takes ( A => Boolean) and returns either a Iterator[A] or collection[A]
I am suggesting an additional method;
convert[B] takes (A => (Boolean, B)) and returns either a Iterator[B] or collection[B]
Note the function passed to convert returns a boolean (to filter or not) in the left tuple slot, and the converted/mapped value in the right tuple slot.
There is a discussion on the topic here, with some solutions that I feel could be greatly improved on with a convert implementation;
(https://stackoverflow.com/questions/32234132/how-to-combine-filter-and-map-in-scala
I have created a rough proof of concept here;
(https://github.com/adligo/scala/blob/2.13.x/src/library/scala/collection/immutable/List.scala
(https://github.com/adligo/scala/blob/2.13.x/test/junit/scala/collection/immutable/Fruit.scala
(https://github.com/adligo/scala/blob/2.13.x/test/junit/scala/collection/immutable/ListTest.scala
I think there are a large number of places where this âconvertâ idea could be used i.e.;
groupConvert
groupConvertReduce
etc.
I think this will reduce the time complexity of the programs by roughly O(n/2) in many cases for large collections!
Adligo .SIP?. B ) l would like Java convenience methods â containsAll ', â removeAll ', â retainAll â added to the Scala collections and additional convenience methods for Maps âcontainsAllKeysâ, âremoveAllKeysâ, âretainAllKeysâ. This also has a external discussion going;
Adligo .SIP?. C ) Scala has a cool method 'combinations( tupleSize : Int)â , I would like a method âcombinations()â added that calculates all the combinations. This is mostly for programming competitions
Thatâs it, again Iâm looking for remote work ( [email protected] ). If I find work I can dedicate some time to implementing much of this, if others also think itâs a good idea. I donât see it changing that much for Scala3, but I also donât know much at all about Scala3 :)_
Merry XMas,
Scott