I'm trying to build a Haskell program that does as the title says. Basically every cell corresponds to the cell before it, the 2nd cell implies that there is just one '1' in the previous cell, and the 3rd cell implies that there is two '1' in the previous cell and so on.
I'm very new to haskell and to it's syntax so I'm getting loads of errors which aren't helpful so I'm using this forum to get some help with it.
This is my code:
findGen :: a -> a
findGen(x) = (getList (x))!!x
getList :: a -> [a]
getList (0) = []
getList (1) = [1]
getList (x) = getList(x-1) : ys where
y = Ord getList(x-1)
zs = group y
ds = countify(zs)
ys = concat(ds)
group :: Eq a => [a] -> [[a]]
group [] = []
group (x:xs) = (x:ys) : group zs where (ys,zs) = span ((==) x )xs
countify :: [a] -> [a]
countify(x:xs) = (y:xs) where y = count(x)
What I was trying to do is like this: FindGen is just a function that returns the n'th element in the sequence. getList is the function that builds the sequence, I was trying to create it using Ord to the previous list so I could group it and then use count to figure out how many times each number appear using countify, and then concating the list making it a string. Trying to figure out where am I wrong, probably in the syntax because I think the idea is good.
Thanks