[Haskell] re:please help!haskell

Peter White muritza at verizon.net
Sat Dec 25 13:51:12 EST 2004


'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, M.I.Azad1 at Bradford.ac.uk 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 misuse at bradford.ac.uk
> ------------------------------------------------------------
>
> _______________________________________________
> Haskell mailing list
> Haskell at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell
>
>
Cheers

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



More information about the Haskell mailing list