This function can certainly be converted into an inline table-valued function. It's tricky, but it can be done and it has nothing to do with parameters as the previous one used parameters as well.
I wanted you to show what have you done even if it's incorrect to be sure that you're understanding what's going on and have some feedback of your progression. I could give you the fish, but I prefer to teach you how to fish. 😉