Cases of functional programming in memory allocation

I read about functional programming, and I was interested to learn about some of the effects for a program in certain cases.

In my current situation, I have a vector in C (an array of two pairs), and often I use this vector in the calculation to get the "returned vector", but I do not want to allocate additional memory, so I use a signature, for example

void compute(vector* input, vector* output);

Where I use overlay on the same input vector to save the output without allocating additional memory for the new output vector.

Now for functional programming, my experience is limited to the Mathematica programming language and a small general lisp, but I'm curious about what effect it will have. Say I have a vector v, and I program the same calculation in a functional language. In Mathematica, I would have a statement:

v = compute(v)

In other standard functional languages, from my understanding of reading is that these objects are immutable, so v should not change, and that v will be reassigned as a new vector, freeing the old vector. I would like to know if my understanding is accurate or not, and if not what happens instead of my misunderstanding. I know a lazy rating, and also would like to know how these systems will differ when used and not use a lazy rating.

Thanks.

1: , . , , - , - , , , - . , , - , , , , :

v = (v)

v . , , - , , ?

+4

All Articles