'list' is poorly named, it produces a rotation by one of the input list (xs)
iterate applies 'list' 0 times, 1 time, 2 times, 3 times, ..., producing an infinite list of all rotations of xs
take (length xs) gets the first (length xs) rotations from the infinite list produced by iterate, this is the final list of rotations by 0,1, ... length xs -1 of the input list xs


On Dec 20, 2004, at 9:15 AM, [EMAIL PROTECTED] wrote:

hi could somebody please explain how everything works in this function? and why
is 'list' there?
any help will be much apprecited
Regards
Imran
all_rotations :: [a] -> [[a]]
all_rotations xs = take (length xs) (iterate list xs)
list xs = tail xs ++ [head xs]


------------------------------------------------------------
This mail sent through IMP: http://webmail.brad.ac.uk
To report misuse from this email address forward the message
and full headers to [EMAIL PROTECTED]
------------------------------------------------------------

_______________________________________________
Haskell mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell


Cheers

Peter White
503 466 0687 (Home)
503 380 8024 (Cell)

_______________________________________________
Haskell mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to