perm_list permutations( int_list the_x ) { x = the_x; perm_CONS( the_x, 0, perms ); P( int_list_length( the_x ) ); return perms; }
void quicksort( int_list *l ) { int *A = malloc( int_list_length(l)*sizeof(int) ); size_t k; k = 0; ABL_BEGIN_LOOP( int_list, l ){ A[k++] = *int_list_get_point( l ); } ABL_END_LOOP( int_list, l );
int compare( const void* pa, const void *pb) { return (*(int*)pa) - (*(int*)pb); } void quicksort( int_list *l ) { int *A = malloc( int_list_length(l)*sizeof(int) ); size_t k; k = 0; ABL_BEGIN_LOOP( int_list, l ){ A[k++] = *int_list_get_point( l ); } ABL_END_LOOP( int_list, l ); qsort( A, int_list_length(l), sizeof(int), compare ); k = 0; ABL_BEGIN_LOOP( int_list, l ){ *int_list_get_point( l ) = A[k++]; } ABL_END_LOOP( int_list, l ); free(A); } int main() { int_list ilst, ilst_comb, ilst_merge, ilst_quick; /* list of ints */ int i; /* iterator */