Hi I\'m trying to rebuild a binary tree, I almost got it, except it throws me an error and I don\'t know why
buildTree :: (Ord a, Eq a) => [a] -> [a] ->
The runtime is failing on this line:
Just rootInd = elemIndex root inOrd
elemIndex is returning Nothing when running your example input, but your code says it will always return a Just, so the runtime crashes. You need to handle the case where elemIndex root inOrd returns Nothing.
Perhaps more importantly, you should enable all warnings with the -Wall flag to show up as compiler errors so that your code wouldn't compile to begin with.