Well you are right to some extent to confuse between the two. A function is a mapping between two sets A and B. Sets A and B can be anything. However what we usually mean by simply "function" is when sets A and B are, loosely speaking, sets of scalars like say the set of real numbers R. When set A and B are sets of (simple) functions then we call the function F:A->B an operator. Example :The operator of indefinite integral takes a function as its argument and return the antiderivative function as its output. When set A is a set of functions and B is a set of scalars then we call the function F:A->B a functional. Example:The functional of definite integral with endpoints a and b takes a function at its input and returns a real number at its output which is the value of the definite integral of that function between two specified points a and b.