Implement a search algorithm that searches through a list for Int n and returns the value in the list before n. If there is no value, or the list is empty, return -1. e.g., findPrev 5 [1,2,3,4,5,6] should return 4, while findPrev 5 [0, 10, 20, 30] returns -1.
I got this for the find the number, but have no idea how to get the previous number. Can someone help and explain this one to me? Here is how I did the first one:
findNext :: Int -> [Int] -> Int
findNext _ [] = -1
findNext n (x:xs)
    | n == x = head xs
    | otherwise = findNext n xs


