I need to create a function in Haskell, that works in the following way
periodicidad :: [Integer] -> [Integer]
periodicidad [1,2,3,4,1,2,3,4...] = [1,2,3,4]
periodicidad [0,1,2,5,4,3,0,1,2,5,4...] = [0,1,2,5,4,3]
That is to say, that from a list you extract the part that is always crawling, what in Mathematical Sciences would be called period of a function.
I tried to group using group
and cycle
, but I do not get anything.
I hope you can help me, I'm stuck and I do not know what to do.