haskell - Rotating a list about an index -


I have a list, say [1, 2, 3, 4, 5] and let me rotate the list an index. For example: 2 [1, 2, 3, 4, 5] will rotate [3, 4, 5, 1, 2]

On online research, Came to the function which eliminates the problem of losing the list, but I feel as if I would benefit greatly from solving my own work with a view to understand, even if it is with less efficient library function The solution for the work is as follows:

to rotate :: int -> [A] - & gt; [ONE] Rotating _ [] = [] Rotate NLL = LE (length L) $ drop n (cycle L)

Can you suggest, without code, this solution Receive alternative ways I can have a crack on them? As I am stuck without ideas, now I have seen this method of doing it!

Cheers

You can do just that:

  rotate nl = drop nl ++ nl  

to obtain without any chakra.


Comments

Popular posts from this blog

HTML/CSS - Automatically set height width from background image? -

php - Mysql Show Process - Sleep Commands and what to do -

c - What is the address of buf (the local variable in the main function)? -