fvasco / jug-2017-07

6 stars 4 forks source link

Scala implementation #2

Closed mattiapiccinetti closed 7 years ago

mattiapiccinetti commented 7 years ago

Hi, here's my version of the project written in Scala. The quicksort algorithm is tested just for few cases. I preferred to copy the source file with the numbers into the resource directory in order to make the scala project self contained.

fvasco commented 7 years ago

Nice, do you think to add the last part of the exercise?

  1. Count occurrences
  2. Print occurrences

Write the ordered numbers is a non goal. Compare Scala output with another one:

1=10
2=10
3=10
4=10
5=10
6=10
7=10
8=10
9=10
10=10
mattiapiccinetti commented 7 years ago

Sure! I'll do it! Thanks!

mattiapiccinetti commented 7 years ago

I'm going to refactor the quickSort method in order to be more generic but I'm struggling with the Ordered[T] inheritance

fvasco commented 7 years ago

Ok, file another pull request.

Spoiler: https://stackoverflow.com/a/2314540

I rewrited Java 8 implementation and I added one in Kotlin 1.1, the big change is to use asynchronous programming instead simple recursion, in addition to improve performance on multi processor machine, this solution avoid StackOverflowError on large lists.

If you feel enough sure then you can try another way.