Ken Dickey wrote: > On Friday 24 October 2008 11:07:25 David Van Horn wrote: >> Ken Dickey wrote: >>> I have not yet found a sorted? predicate used in an induction >>> loop. >> There is an implicit use here (adapted from HtDP), by appealing to fact >> that (sorted? null) is #t. >> >> (define (sort alon) >> (cond >> [(null? alon) null] >> [else (insert (car alon) (sort (cdr alon)))])) >> >> David > > No. The induction is on the length of the list with the termination > condition > that the list is empty. > > If you substitute 'sorted? for 'null? you would be moving toward slow-sort, > where the entire collection is sorted, the least element noted, the entire > collection sorted again ...
I think you have misread the code (I nearly did). It looks like an insertion sort to me... > ;^) > > -KenD > > > _______________________________________________ > r6rs-discuss mailing list > [email protected] > http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss _______________________________________________ r6rs-discuss mailing list [email protected] http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss
