searchfunc :: Integer -> [Integer]
searchfunc target = rec_search 0 [] $  reverse (takeWhile (<target) squares)
                    where
                      rec_search :: Integer -> [Integer] -> [Integer] -> [Integer]
                      rec_search sm [] [] = []
                      rec_search sm l1 [] = 
                          if sm == target then l1 else 
                              if sm > target then 
                                 rec_search (sm - head l1) (tail l1) []
                              else []
                      rec_search sm l1 l2 =
                          if sm > target then rec_search (sm - head l1) (tail l1) l2
                          else if sm < target then rec_search (sm + head l2) (l1 ++ [head l2]) (tail l2)
                               else l1
searchfunc :: Integer -> [Integer]
searchfunc target = rec_search 0 [] $  reverse (takeWhile (<target) squares)
                    where
                      rec_search :: Integer -> [Integer] -> [Integer] -> [Integer]
                      rec_search sm [] [] = []
                      rec_search sm l1 [] = 
                          if sm == target then l1 else 
                              if sm > target then 
                                 rec_search (sm - head l1) (tail l1) []
                              else []
                      rec_search sm l1 l2 =
                          if sm > target then rec_search (sm - head l1) (tail l1) l2
                          else if sm < target then rec_search (sm + head l2) (l1 ++ [head l2]) (tail l2)
                               else l1
searchfunc target = rec_search 0 [] $  reverse (takeWhile (<target) squares)
                    where
                      rec_search :: Integer -> [Integer] -> [Integer] -> [Integer]
                      rec_search sm [] [] = []
                      rec_search sm l1 [] = 
                          if sm == target then l1 else 
                              if sm > target then 
                                 rec_search (sm - head l1) (tail l1) []
                              else []
                      rec_search sm l1 l2 =
                          if sm > target then rec_search (sm - head l1) (tail l1) l2
                          else if sm < target then rec_search (sm + head l2) (l1 ++ [head l2]) (tail l2)
                               else l1