Implemented a function `filter(x, test)`