select and selectSplit

Isaac Dupree isaacdupree at charter.net
Fri Feb 15 17:11:55 EST 2008


Aaron Denney wrote:
> On 2008-02-15, Cale Gibbard <cgibbard at gmail.com> wrote:
>> -- | The 'select' function takes a list and produces a list of pairs
>> -- consisting of an element of the list together with a list of the
>> -- remaining elements.
>> select :: [a] -> [(a,[a])]
>> select [] = []
>> select (x:xs) = (x,xs) : [(y,x:ys) | (y,ys) <- select xs]
> 
> A couple tounge-in-cheek suggestions:
> 
> "banishments" -- all possible ways a society can divide itself up into
> one banished person, and the rest of society.

thank you for that name!!! It finally helped me figure out what the 
function was supposed to do.

now, documentation that included examples would be nearly as good...
select [1,2,3,4] = [(1,[2,3,4]), (2,[1,3,4]), (3,[1,2,4]), (4,[1,2,3])] 
--right?

or we could call it "howToAbductEachElement" ;-) but that belongs in the 
Haskell list library even less than "banishments"


More information about the Libraries mailing list