Re: Permutations of a list

2001-05-14 Thread Andy Fugard
At 13:43 14/05/01 +0200, Ralf Hinze wrote: >Andy Fugard wrote: > > > My main question is really what facilities of the language I should be > > looking at to make this code more elegant! As you can see I currently know > > only the basics of currying, and some list operations. > >Definitely list

Re: Permutations of a list

2001-05-14 Thread Ralf Hinze
Andy Fugard wrote: > My main question is really what facilities of the language I should be > looking at to make this code more elegant! As you can see I currently know > only the basics of currying, and some list operations. Definitely list comprehensions! I digged out some old code: > module

Permutations of a list

2001-05-14 Thread Andy Fugard
Hi all, I'm currently teaching myself a little Haskell. This morning I coded the following, the main function of which, permutate, returns all the permutations of a list. (Well it seems to at least!) insertAt :: a -> Int -> [a] -> [a] insertAt x i xs | i < 0 || i >