I am studying JavaFX Script and trying to compare it to Scala, which is another very interesting new language for the Java platform.
In the official Scala site I found this example, which is a Quick Sort implementation. I then wrote the following equivalent JavaFX Script program (using NetBeans IDE 6.7.1):
package examples;
function sort(a: Integer[]): Integer[] {
if (sizeof a < 2)
a
else {
def pivot = a[sizeof a / 2];
[sort(a[n | n < pivot]), a[n | n == pivot], sort(a[n | n > pivot])];
}
}
function run(args: String[]) {
def xs = [6, 2, 8, 5, 1];
println(xs);
println(sort(xs));
}
Both functional programs are very similar, but I like the JavaFX version better. Those "_" and ":::" parts in the Scala version don't look very appealing to me...
Of course, there is a lot more to both languages, so I am looking for more examples. Does anybody know where I can find some? Or even better, post other examples here?