Just for fun, here's how quicksort can be implemented in Fantom in a single expression:
Obj[] qsort(Obj[] data) { data.size < 2 ? data : qsort(data[1..-1].findAll { it < data.first} ).add(data.first) .addAll(qsort(data[1..-1].findAll { it >= data.first})) }
Edit: fixed bug with skipping repeated elements
All I can say is ouch...
Login or Signup to reply.
ivan Mon 5 Jul 2010
Just for fun, here's how quicksort can be implemented in Fantom in a single expression:
Edit: fixed bug with skipping repeated elements
DanielFath Mon 5 Jul 2010
All I can say is ouch...