[Haskell-cafe]  \\ [1..] diverges - intended?
difrumin at gmail.com
Mon Jul 28 14:10:38 UTC 2014
On Sun, Jul 27, 2014 at 12:55 AM, Henk-Jan van Tuyl <hjgtuyl at chello.nl> wrote:
> On Sat, 26 Jul 2014 21:39:01 +0200, Niklas Hambüchen <mail at nh2.me> wrote:
>> I just noticed that
>> import Data.List
>>  \\ [1..]
>> diverges, although technically it doesn't have to (the docs suggest to
>> me that it could just be , and a non-diverging implementation is
>> Same for [1,2] \\ [1..] of course.
> You can define (\\) as follows, terminating in case of the samples you gave:
> (\\) :: (Eq a) => [a] -> [a] -> [a]
> (\\)  _ = 
> (\\) _  = 
> (\\) xs (y : ys) = delete y xs \\ ys
Is this actually correct? Shouldn't the second line be
(\\) x  = x
> but this will not terminate in cases like:
>  \\ [1..]
> I don't think there is a way to get this terminating for all cases.
> Henk-Jan van Tuyl
> Folding at home
> What if you could share your unused computer power to help find a cure? In
> just 5 minutes you can join the world's biggest networked computer and get
> us closer sooner. Watch the video.
> Haskell programming
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe