You can cope with this problem with Common Table Expressions(CTEs) very easily. I mean nested ones. For example :
with cte1(...) as
(
select some rows
), cte2(...) as
(
do what ever you want with each row of cte1 (in this case implement your function here for each row)
), cte3(...) as
(
do other things with each row of cte2
)
select * from cte3
By this way you can convert any function into a simple select statement.
Hope it helps