The function swaps the first and last characters of the input string and reverses the order of the remaining characters in between.

[CODE]:
```python
def f(x):
    if len(x) <= 1:
        return x
    else:
        return x[-1] + x[1:-1][::-1] + x[0]
```