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 ...

;^)

-KenD


_______________________________________________
r6rs-discuss mailing list
r6rs-discuss@lists.r6rs.org
http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss

Reply via email to