Quicksort in Haskell vs. quicksort in C++

FUCK THE POLICE

911 EVERY DAY
Haskell:

Code:
quicksort :: (Ord a) => [a] -> [a]  
quicksort [] = []  
quicksort (x:xs) =   
    let smallerSorted = quicksort [a | a <- xs, a <= x]  
        biggerSorted = quicksort [a | a <- xs, a > x]  
    in  smallerSorted ++ [x] ++ biggerSorted

C++:

Code:
void quicksort(int a[], int left, int right)
{
	if (left < right)
	{
		int pivot = partition(a, left, right);
		quicksort(a, left, pivot-1);
		quicksort(a, pivot+1, right);
	}
}
int partition(int a[], int left, int right)
{
	int pivot = a[left];
	while (true)
	{
		while (a[left] < pivot) left++;
		while (a[right] > pivot) right--;
		if (left < right)
		{
			swap(a[left], a[right]);
		}
		else
		{
			return right;
		}
	}
}
 
I'd vote for the first one because i like my lower case a's to be in little boxes [a].

That's a linked list. I once spent 6 hours writing one of those in c++. Not nearly as difficult as a fucking goddamn tree... fucking fuck fuck shit shit fuck trees. Fuck trees. Fuck trees.
 
30251_tree_hole.jpg
 
Back
Top