[plt-scheme] HtDP 26.1.2

From: Marco Morazan (morazanm at gmail.com)
Date: Sun Mar 22 10:34:14 EDT 2009

On Sat, Mar 21, 2009 at 7:50 PM, David Yrueta <dyrueta at gmail.com> wrote:
> How can this accomplished --
> (check-expect (merge-all-neighbors (list (list 9) (list 1))) (list (list 1
> 9)))?
>
> -- without some sorting going on within "merge-all-neighbors"?

Your function, merge-all-neighbors, needs to process two pieces of
data of arbitrary size. You need to decide how both pieces of data
have to be processed. Do you only need to traverse one list at a time?
Do you need to traverse both lists at the same time?

There is also an assumption that you seem to not have picked up. In
addition to being (listof number), what other property should you
assume each of the inputs has? Is (merge-all-neighbors (list 2 1)
(list 8 9)) a "legal" application of merge-all-neighbors to two lists
of numbers?

After figuring out the above, I suggest you think about how
(merge-all-neighbors (list 2 8 9) (list 1 3 7 10)) can yield (list1 2
3 7 8 9 10). This should tell you how the inputs need to be processed.


-- 

Cheers,

Marco


Posted on the users mailing list.