Added solution for Swift.

This solution cheats a little by using subscripting rather than function calls, but I feel that it solves the puzzle in spirit.