Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ListLike l where
- type Elem l
- indexl :: l -> Int -> Elem l
- instance ListLike (V.Vector a) where
- type Elem (V.Vector a) = a
- indexl = (V.!)
- instance ListLike [a] where
- type Elem [a] = a
- indexl = (!!)
- cutrod ::
- forall l.
- ListLike l =>
- l ->
- Int ->
- Int
- cutrod v n = go 1 0
- where
- go l result | l == n + 1 = result
- go l result | otherwise = go (l + 1) result'
- where
- result' = maximum [result + (indexl v 0), (indexl v (l - 1))]
- src/MyLib.hs:50:38-47: error: …
- • Couldn't match expected type ‘Int’ with actual type ‘Elem l’
- • In the second argument of ‘(+)’, namely ‘(indexl v 0)’
- In the expression: result + (indexl v 0)
- In the first argument of ‘maximum’, namely
- ‘[result + (indexl v 0), (indexl v (l - 1))]’
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement