I have come up with this myself ^_^<br><br>mps :: [a] $B"*(B [[a]] $B"*(B [[a]]<br>mps [] _ = []<br>mps _ [] = []<br>mps (x:xs) yss = map (x:) yss ++ mps xs yss<br><br>pms :: [a] $B"*(B Int $B"*(B [[a]]<br>pms [] _ = [[]]<br>pms _ 0 = [[]]<br>
pms xxs n = mps xxs (pms (xxs) (n - 1))<br><br>-- now bpms can pointlessly be redefined as<br><br>bpms = pms [False,True]<br><br><div><span class="gmail_quote">On 26/01/2008, <b class="gmail_sendername">Cetin Sert</b> <<a href="mailto:cetin.sert@gmail.com">cetin.sert@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<span style="font-family: courier new,monospace;">How can I make a generic permutations function?<br><br>-- boolean permutations</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">bpms :: Int $B"*(B [[Bool]]</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">bpms 0 = [[]]</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">bpms n = map (False:) bss ++ map (True:) bss</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> where</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> bss = bpms (n - 1)</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">-- generic</span> permutations<br>pms a :: Int <span style="font-family: courier new,monospace;">$B"*(B [[a]]<br><br>Best Regards,<br>
Cetin Sert<br></span>
</blockquote></div><br>