Trying to write function that numerize items of list and returns list of tuples with numbers, ya I know I can do it with 'zip' function, but task is to write it with recursion: so I get
cannot construct an infinite type: a = [a] when generalizing type(s) for numerize'
What am I doing wrong?
numerize' :: [a] -> Int -> [(a, Int)]
numerize' [] _ = []
numerize' [x] n = [(x, n)]
numerize' [x:xs] n = (x, n) : numerize' xs (n + 1)
[x:xs]
should be
(x:xs)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With