Function generating functions

As a new user, I’d also like to point out that use a comprehension with the [ ] isn’t necessary, and you can instead use the generator expression. So instead, you would do sum(p[i]*(x.^i./factorial(i)) for i in 1:k). Notice the brackets were removed. Multi-dimensional Arrays · The Julia Language

With the array comprehension with the brackets, the vector is allocated memory, calculated for each element, then it is summed. With the generated expression, it is calculated and summed without allocating any memory.

4 Likes