Iteration doesn't exist in functional programming. If you ever used iteration in FP you're doing it wrong.
So I ask you... how does a functional program do the algorithm you ask for above?
Recursion and the ternary operator. All iterative programs can be written in recursion and vice versa.
Another way of thinking about this is rather then formula, think expression. Functional programming is about coding up an expression that can fit on one line.
Anything that breaks the program into multiple lines means you're turning your functional expression into a list of procedures.
So I ask you... how does a functional program do the algorithm you ask for above?
Recursion and the ternary operator. All iterative programs can be written in recursion and vice versa.
Another way of thinking about this is rather then formula, think expression. Functional programming is about coding up an expression that can fit on one line.
Anything that breaks the program into multiple lines means you're turning your functional expression into a list of procedures.