# [plt-scheme] Htdp chapter 12 insertion sort

>* ;; sort : list-of-numbers -> list-of-numbers (sorted)
*>*
*>* ;; to create a list of numbers with the same numbers as
*>* ;; alon sorted in descending order
*>* (define (sort alon)
*>*
*>* (cond
*>* [(empty? alon) empty]
*>* [(cons? alon) (insert (first alon) (sort (rest alon)))]))- what is cons?
*>* alon here , is it required there?
*
What exactly is bothering you? cons? is a primitive used to determine
if its input is a constructed list. Given that the contract guarantees
a (listof number) as input, you can substitute (cons? alon) with else
in the above function. In other words, given the above contract there
is not need to check if alon is a constructed list after knowing it is
not an empty list.
--
Cheers,
Marco