Re: Haskell problem please help

N.B. if you want a faster answer such questions are best posted to haskell-cafe@haskell.org My answer: I asume that your function all_rotations somehow needs to be called recursively for the rest of the input list xs. Cheers Christian imranazad wrote:
Hi,
im not very good with haskell, i barely know the basics, my coursework requires me to genereate a vigenere square....... well anyway at the moment im trying to define a functin all_rotations which for any list returns the list of all its rotations, so far i've made an attempt but it only rotates once....any ideas? i dont want the complete solution just help thats all, much appreciated.
all_rotations :: [a] -> [[a]] all_rotations [] = [] all_rotations (x:xs) = reverse (x:xs) : []

imranazad wrote:
Hi,
im not very good with haskell, i barely know the basics, my coursework requires me to genereate a vigenere square....... well anyway at the moment im trying to define a functin all_rotations which for any list returns the list of all its rotations, so far i've made an attempt but it only rotates once....any ideas?, much appreciated.
all_rotations :: [a] -> [[a]] all_rotations [] = [] all_rotations (x:xs) = reverse (x:xs) : [] regards, imran
------------------------------------------------------------ This mail sent through IMP: http://webmail.brad.ac.uk To report misuse from this email address forward the message and full headers to misuse@bradford.ac.uk ------------------------------------------------------------

imranazad wrote:
Hi,
im not very good with haskell, i barely know the basics, my coursework requires me to genereate a vigenere square....... well anyway at the moment im trying to define a functin all_rotations which for any list returns the list of all its rotations, so far i've made an attempt but it only rotates once....any ideas? i dont want the complete solution just help thats all, much appreciated.
all_rotations :: [a] -> [[a]] all_rotations [] = [] all_rotations (x:xs) = reverse (x:xs) : []
'cycle' the list, then determine all of its suffixes with 'tails' and take the first elements of each list.

On 2004-12-16 at 17:00+0100 Henning Thielemann wrote:
imranazad wrote:
Hi,
im not very good with haskell, i barely know the basics, my coursework requires me to genereate a vigenere square....... well anyway at the moment im trying to define a functin all_rotations which for any list returns the list of all its rotations, so far i've made an attempt but it only rotates once....any ideas? i dont want the complete solution just help thats all, much appreciated.
all_rotations :: [a] -> [[a]] all_rotations [] = [] all_rotations (x:xs) = reverse (x:xs) : []
'cycle' the list, then determine all of its suffixes with 'tails' and take the first elements of each list.
playing with inits l `zip` tails l might also be edifying. -- Jón Fairbairn Jon.Fairbairn@cl.cam.ac.uk
participants (4)
-
Christian Maeder
-
Henning Thielemann
-
Jon Fairbairn
-
M.I.Azad1@Bradford.ac.uk