Thank you for the comprehensive reply Yitzchak.
On Wed, Aug 5, 2009 at 2:22 PM, Yitzchak Gale wrote:
> Hi Slavomir,
>
> Slavomir Kaslev wrote:
>>> inter x [] = [[x]]
>>> inter x yys@(y:ys) = [x:yys] ++ map (y:) (inter x ys)
>>
>>> perm [] = [[]]
>>> perm (x:xs) = concatMap (inter x) (perm xs)
>>
>
Hi Slavomir,
Slavomir Kaslev wrote:
>> inter x [] = [[x]]
>> inter x yys@(y:ys) = [x:yys] ++ map (y:) (inter x ys)
>
>> perm [] = [[]]
>> perm (x:xs) = concatMap (inter x) (perm xs)
>
> I was surprised to find that not only my version is much simpler from the one
> in Data.List but it also perform
Your function is not equivalent:
perm _|_ = _|_
permutations _|_ = _|_ : _|_
I have a vague memory that the library version diagonalises properly,
so that if you give it a lazy infinite input, it still generates
sensible output lazily. If so, this important property should be
noted in t
Am Dienstag 04 August 2009 20:30:58 schrieb Slavomir Kaslev:
> On Tue, Aug 4, 2009 at 9:23 PM, Daniel Fischer
> wrote:
>
> Which version of ghc are you testing on? I guess, it's more recent than
> mine.
6.10.3. But I think if you compiled it with 6.8.*, the library code would still
be faster,
On Tue, Aug 4, 2009 at 9:23 PM, Daniel Fischer wrote:
> Am Dienstag 04 August 2009 19:48:25 schrieb Slavomir Kaslev:
>> A friend mine, new to functional programming, was entertaining himself by
>> writing different combinatorial algorithms in Haskell. He asked me for some
>> help so I sent him my q
Am Dienstag 04 August 2009 19:48:25 schrieb Slavomir Kaslev:
> A friend mine, new to functional programming, was entertaining himself by
> writing different combinatorial algorithms in Haskell. He asked me for some
> help so I sent him my quick and dirty solutions for generating variations
> and
>
On Tue, Aug 4, 2009 at 8:53 PM, Krasimir Angelov wrote:
> Your function is not equivalent:
>
> perm _|_ = _|_
>
> permutations _|_ = _|_ : _|_
Nice catch. One can use the same trick as in permutations:
> perm2 [] = [[]]
> perm2 xxs@(x:xs) = xxs : tail (concatMap (inter x) (perm2 xs))
I've just n
Your function is not equivalent:
perm _|_ = _|_
permutations _|_ = _|_ : _|_
On 8/4/09, Slavomir Kaslev wrote:
> A friend mine, new to functional programming, was entertaining himself by
> writing different combinatorial algorithms in Haskell. He asked me for some
> help so I sent him my quick
A friend mine, new to functional programming, was entertaining himself by
writing different combinatorial algorithms in Haskell. He asked me for some
help so I sent him my quick and dirty solutions for generating variations and
permutations:
> inter x [] = [[x]]
> inter x yys@(y:ys) = [x:yys] ++ m