Cas wishes to calculate some maths formulae...
I want to write a function that takes a string and returns a function.
The string that this function takes should be a formula (for example "y=ax+b")
There's another Paul who teaches Swift and XCode development: Paul Hagerty of Stanford University.
For a few semesters he developed a RPN calculator during his lectures. (The lectures may be old, but the logic is still sound!) His logic follows the keystrokes as a user enters a formula into the calculator's keyboard. This sounds similar to what you wish to accomplish.
His logic describes how he captures unary maths operations, such as taking the negative of a number, or squaring a number. He also describes binary operations that take two double values and one operand such as a plus sign, or a divide sign. His logic pushes numbers (10, 42, 3.14, etc) into a stack and then operates on the stack when an operator is encountered (+, -, ^, etc).
You may want to watch his series, and also explore the CalculatorBrain.swift logic that some students have posted to github. I have provided one such link below. Operand order is important! You need a clever data structure to parse a string version of a formula from left to right.
This hint may, or may not, help you think through your logic problem.
Good luck!
Keep coding!
Watch the lectures! This will help you grok the code.
See -> CS 193p Calculator Code