[clean-list] Help with list comprehension
Ronny Wichers Schreur
ronny@cs.kun.nl
Wed, 06 Jun 2001 14:13:38 +0200
Extreme programmer Jerzy Karczmarczuk writes his test case
>Say, insrt x
> into [a,b,c] should yield [[x,a,b,c],[a,x,b,c],[a,b,x,c],[a,b,c,x]].
before his function
> insrt x [] = [[]]
> insrt x l=:[y:yq] = [[x:l] : [[y:s] \\ s<-insrt x yq]]
but forgot to apply the unit test:
Start
= insrt 'x' ['abc'] == [['xabc'],['axbc'],['abxc'],['abcx']]
==> False
or he would have found the fix
insrt x [] = [[x]]
insrt x l=:[y:yq] = [[x:l] : [[y:s] \\ s<-insrt x yq]]
Cheers,
Ronny Wichers Schreur