d=lambda x:("{"+d(x//4)+"}"if x>3 else"")+";"*(x%4)

In this implementation, c is the function that satisfies the requirements. It returns a string if given an nonnegative integer as input, or an integer if given a curly number as input.