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

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -