Thanks for your reply. I tried a&nbsp;few ways but&nbsp;none&nbsp;worked.<br><br>One is&nbsp;like:<br> <br><font face="courier new,monospace">shorter as bs =  f id id as bs where<br>&nbsp;&nbsp;&nbsp;&nbsp;f ca cb [] _ =&nbsp;ca&nbsp;[] <br> &nbsp;&nbsp;&nbsp;&nbsp;f ca cb _ [] = cb []<br>&nbsp;&nbsp;&nbsp;&nbsp;f ca cb (a:as) (b:bs) = f (ca.(a:)) (cb.(b:)) as bs
</font><br><br>However this will result in a non-terminating loop for shorter [1..] [2..],<br>since&nbsp;the&nbsp;first&nbsp;two&nbsp;patterns&nbsp;of&nbsp;f&nbsp;shall never&nbsp;match.<br><br>Another way, I could guarantee that the evaluation  of<br>shorter [1..5] (shorter [1..] [2..])
<br>terminate but&nbsp;I lose the information to   figure out which&nbsp;list&nbsp;was&nbsp;the shortest&nbsp;one.<br>Using zips:<br><br><font face="courier new,monospace">shorter = zipWith (\a&nbsp;b&nbsp;-&gt; undefined) <br>-- this   returns the length,&nbsp;but&nbsp;not&nbsp;the&nbsp;content&nbsp;of&nbsp;the&nbsp;shorter list
</font><br><br>(\a&nbsp;b&nbsp;-&gt;&nbsp;undefined) could be replaced with something that encode the contents of<br>the two lists, but  it makes no difference since I won't know which one is the answer.<br><br>The difficulty is that I cannot   have these both:
<br>A. if&nbsp;one&nbsp;list&nbsp;is&nbsp;finite,&nbsp;figure&nbsp;out&nbsp;the&nbsp;shorter&nbsp;one <br>B. if both are infinite, returning an infinite list could work<br><br>BTW, there   IS an way to implement this functionality for a finite list of (possibly infinite) lists:
<br><font face="courier new,monospace"><br>shortest = measureWith [] where<br>&nbsp;&nbsp;&nbsp;&nbsp;measureWith ruler as = f matches<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;where ruler' = undefined : ruler<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;matches = filter p as<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p a = length (zip ruler' a) == length (zip ruler a)
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;f [] = measureWith ruler' as<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;f matches = matches<br></font><br>which somehow makes it unnecessary to   find the function &quot;shorter&quot;,<br><br>but the original simple problem is interesting itself.
<br><br>Thanks.<br><br><div><span class="gmail_quote">On 10/10/06, <b class="gmail_sendername">Neil Mitchell</b> &lt;<a href="mailto:ndmitchell@gmail.com">ndmitchell@gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; margin-left: 0.80ex; border-left-color: #cccccc; border-left-width: 1px; border-left-style: solid; padding-left: 1ex">
Hi,<br><br>The trick is not call &quot;length&quot;, since length demands the whole of a<br>list, and won't terminate on an infinite list. You will want to<br>recurse down the lists.<br><br>Is this a homework problem? It's best to declare if it is, and show
<br>what you've managed to do so far.<br><br>Thanks<br><br>Neil<br><br></blockquote></div><br>