I am trying to generate a list of perfect squares between 2 values i and n using recursion and guards. I can achieve this with list comprehension (i is not taken as an argument):
isPerfectSquare :: Integral a => a -> Bool
isPerfectSquare n = sq * sq == n
where sq = floor(sqrt(fromIntegral n :: Double))
squares :: Int -> [Int]
squares x = [y | y <- [1..x], isPerfectSquare y]
But I'm having trouble using recursion and guards for this. I'm trying to implement this without using higher order functions or list comprehension. I would appreciate someone pointing me in the right direction.