[plt-scheme] HtDP 26.1.2

From: Jordan Johnson (jmj at fellowhuman.com)
Date: Sat Mar 21 21:02:11 EDT 2009

On Mar 21, 2009, at 3:26 PM, dave yrueta wrote:
> The text describes the contract for "merge-neighbors" as a function
> which "merges pairs of neighboring lists. More specifically, it
> consumes a list of lists (of numbers) and merges neighbors. For
> example,
> (equal? (merge-all-neighbors (list (list 2) (list 5) (list 9) (list
> 3)))
>         (list (list 2 5) (list 3 9))) "
> In the example, however, it seems that in addition to merging pairs of
> neighboring lists, "merge-neighbors" also sorts each pair of lists in
> ascending order before combining them...

No; in the examples, the input to merge-all-neighbors is actually a  
list of sorted lists already.  merge-all-neighbors just has to merge  
these sorted lists in such a way as to produce sorted result lists.


Posted on the users mailing list.