I am trying to create a function that lists the differences in another list. So for [1,3,7,11] he will be back [2,4,4]. I am trying to use list comprehension, but I am having problems with the types of functions that I wanted to use. Is it possible to save this format by converting [t] to [int] and back to [t] again?
{ difflist x y = [ p - q | p<- [x..y],
q<- [ ( [1..(length [x..y]) ] !! [x..y] ): []]] }
<interactive>:200:70: error:
• Couldn't match expected type ‘Int’ with actual type ‘[[Int]]’
• In the second argument of ‘(!!)’, namely ‘[x .. y]’
In the first argument of ‘(:)’, namely
‘([1 .. (length [x .. y])] !! [x .. y])’
In the expression: ([1 .. (length [x .. y])] !! [x .. y]) : []
source
share