Hi,

The trick is not call "length", since length demands the whole of a
list, and won't terminate on an infinite list. You will want to
recurse down the lists.

Is this a homework problem? It's best to declare if it is, and show
what you've managed to do so far.

Thanks

Neil

On 10/10/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Hi all,

I'm trying to implement a function that returns the shorter one of two given
lists,
something like
shorter :: [a] -> [a] -> [a]
such that shorter [1..10] [1..5] returns [1..5],
and it's okay for shorter [1..5] [2..6] to return either.

Simple, right?

However, it becomes difficult when dealing with infinite lists, for example,
shorter [1..5] (shorter [2..] [3..])
Could this evaluate to [1..5]? I haven't found a proper implementation.

Again it's ok for shorter [2..] [3..] to return whatever that can solve the
above problem correctly.
An infinite list could work, I guess, but I don't know how.

Thanks for any help.


_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe



_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to