Beautiful Code

วันนี้ได้ไปอ่านหนังสือ Beautiful Code มา มีตอนนึงเค้าเขียนไว้ว่า

?A designer knows he has achieved perfection not when there is nothing left to add, but when there is nothing left to take away.?

void quicksort(int l, int u){
     int i, m;
     if (l >= u){
     swap(l, randint(l, u));
     m = l;
     for (i = l+1; i <= u; i++){
          if (x[i] < x[l]){
               swap(++m, i);
     swap(l, m);
     quicksort(l, m-1);
     quicksort(m+1, u);

เปงไง Beautiful ไหม?..

3 responses to “Beautiful Code”

  1. d0m3z Avatar

    surprisingly, it can be as short as this!

  2. admin Avatar

    Thank Krub

Leave a Reply

Your email address will not be published. Required fields are marked *